Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

CellFormat Object (Excel)

Represents the search criteria for the cell format.

Use the FindFormat or ReplaceFormat properties of the Application object to return a CellFormat object.

With a CellFormat object, you can use the Borders , Font , or Interior properties of the CellFormat object, to define the search criteria for the cell format.

The following example sets the search criteria for the interior of the cell format.

Sub ChangeCellFormat() 
 ' Set the interior of cell A1 to yellow. 
 Selection.Interior.ColorIndex = 36 
 MsgBox "The cell format for cell A1 is a yellow interior." 
 ' Set the CellFormat object to replace yellow with green. 
 With Application 
 .FindFormat.Interior.ColorIndex = 36 
 .ReplaceFormat.Interior.ColorIndex = 35 
 End With 
 ' Find and replace cell A1's yellow interior with green. 
 ActiveCell.Replace What:="", Replacement:="", LookAt:=xlPart, _ 
 SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=True, _ 
 MsgBox "The cell format for cell A1 is replaced with a green interior." 
End Sub
© 2015 Microsoft