应用于 CellFormat 对象的 CellFormat 属性。
本示例设置搜索条件以识别包含红色字体的单元格,应用该条件创建一个单元格,找到该单元格,并通知用户。
Sub SearchCellFormat()
' Set the search criteria for the font of the cell format.
Application.FindFormat.Font.ColorIndex = 3
' Set the color index of the font for cell A5 to red.
Range("A5").Font.ColorIndex = 3
Range("A5").Formula = "Red font"
Range("A1").Select
MsgBox "Cell A5 has red font"
' Find the cells based on the search criteria.
Cells.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=True).Activate
MsgBox "Microsoft Excel has found this cell matching the search criteria."
End Sub
本示例判断单元格 A1 的字体名称是否为 Arial,并通知用户。
Sub CheckFont() Range("A1").Select ' Determine if the font name for selected cell is Arial. If Range("A1").Font.Name = "Arial" Then MsgBox "The font name for this cell is 'Arial'" Else MsgBox "The font name for this cell is not 'Arial'" End If End Sub