且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

搜索加粗格式的单元格

更新时间:2023-11-29 13:07:40

这是您如何在工作表的E列中查找前两个粗体单元格(偏移量以在它们之间创建范围)的方式,与内容无关.如果您想要某些内容的粗体文本,则可以用文本替换*.如前所述,如果要查找所有粗体单元格,则需要创建一个循环.

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