应用于 CellFormat 对象的 Borders 属性。
允许用户设置或返回基于单元格边框格式的搜索条件。
expression.Borders
expression 必需。该表达式返回一个 CellFormat 对象。
应用于 FormatCondition、Range 和 Style 对象的 Borders 属性。
有关返回集合中单个成员的详细信息,请参阅返回集合中的对象。
应用于 CellFormat 对象的 Borders 属性。
本示例设置搜索条件以识别单元格的边框,这些单元格具有连续、加粗样式的底部边缘。创建一个满足该条件的单元格,然后找到该单元格并通知用户。注意:本示例中的边框使用了默认颜色,因此颜色索引值没有更改。
Sub SearchCellFormat()
' Set the search criteria for the border of the cell format.
With Application.FindFormat.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThick
End With
' Create a continuous thick bottom-edge border for cell A5.
Range("A5").Select
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThick
End With
Range("A1").Select
MsgBox "Cell A5 has a continuous thick bottom-edge border"
' 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
应用于 FormatCondition、Range 和 Style 对象的 Borders 属性。
本示例将 Sheet1 中单元格 B2 的底部边框颜色设置为红色。
Sub SetRangeBorder()
With Worksheets("Sheet1").Range("B2").Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 3
End With
End Sub