Excel) (CellFormat 物件
代表儲存格格式的搜尋準則。
使用 Application物件的FindFormat或ReplaceFormat屬性可傳回CellFormat物件。
使用CellFormat物件的Borders、Font或Interior屬性來定義儲存格格式的搜尋準則。
下列範例會設定儲存格內部格式的搜尋準則。
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
- AddIndent
- Application
- Borders
- Creator
- Font
- FormulaHidden
- HorizontalAlignment
- IndentLevel
- Interior
- Locked
- MergeCells
- NumberFormat
- NumberFormatLocal
- Orientation
- Parent
- ShrinkToFit
- VerticalAlignment
- WrapText
有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。