Searching for Bold formatted Cells

时光怂恿深爱的人放手 提交于 2020-07-10 07:45:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!