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. 
 Range("A1").Select 
 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, _ 
 ReplaceFormat:=True 
 MsgBox "The cell format for cell A1 is replaced with a green interior." 
 
End Sub

Community Additions

ADD
Show:
© 2014 Microsoft