Font Property

Microsoft Excel Visual Basic

Returns a Font object, allowing the user to set or return the search criteria based on the cell's font format.

expression.Font

expression    Required. An expression that returns one of the above objects.

ShowFont property as it applies to all other objects in the Applies To list.

Returns a Font object that represents the font of the specified object.

expression.Font

expression    Required. An expression that returns one of the above objects.

Example

ShowAs it applies to the CellFormat object.

This example sets the search criteria to identify cells that contain red font, creates a cell with this condition, finds this cell, and notifies the user.

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

				

ShowAs it applies to all other objects in the Applies To list.

This example determines the if the font name for cell A1 is Arial and notifies the user.

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