CellFormat 对象 (Excel)
代表单元格格式的搜索条件。
备注
使用 Application 对象的 FindFormat 或 ReplaceFormat 属性可返回 CellFormat 对象。
使用 CellFormat 对象的“边框”、“字体”或“内部”属性定义单元格格式的搜索条件。
示例
下例设置单元格格式内部的搜索条件。
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 支持和反馈,获取有关如何接收支持和提供反馈的指南。
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈