问题
I am trying to set a range of cells between bold cells. Here is what I have so far:
With Worksheets("FC01.RPT")
.Cells(.Rows.Count, 1).End(xlUp).Offset(2) = "Individual Rate Guest"
Instead of using "Individual Rate Guest", how can I write it so that it will look for a bold format?
Thanks!
回答1:
This is how you would find the first two bold cells (offset to create a range between) in Column E of your worksheet regardless of content. You can replace the *
with text if you wanted bold text of a certain content. As mentioned, if you wanted to find all bold cells, you would need to create a loop.
Sub FindBoldCells()
Dim boldcell As Range
Dim boldcell2 As Range
Application.FindFormat.Clear
Application.FindFormat.Font.Bold = True
With Worksheets("FC01.RPT")
Set boldcell = .Range("E:E").Find("*", SearchFormat:=True).Offset(1, 0)
Set boldcell2 = .Range("E:E").Find("*", After:=boldcell, SearchFormat:=True).Offset(-1, 0)
End With
End Sub
来源:https://stackoverflow.com/questions/49759149/searching-for-bold-formatted-cells