Notatka
Dostęp do tej strony wymaga autoryzacji. Może spróbować zalogować się lub zmienić katalogi.
Dostęp do tej strony wymaga autoryzacji. Możesz spróbować zmienić katalogi.
Returns a Borders collection that represents the borders of a style or a range of cells (including a range defined as part of a conditional format).
Syntax
expression.Borders
expression A variable that represents a FormatCondition object.
Remarks
For Border objects returned by this collection, you can set supported border properties for the top, bottom, left, and right borders. However, reading the LineStyle or Weight property isn't supported and can raise run-time error 1004 (COM error 0x800A03EC), even when the border was configured in the Conditional Formatting dialog.
This limitation doesn't apply to Range.Borders.
Example
This example sets the color of the bottom border of cell B2 on Sheet1 to a thin red border.
Sub SetRangeBorder()
With Worksheets("Sheet1").Range("B2").Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 3
End With
End Sub
This example sets the bottom border of the first conditional-format rule for cell B2 on Sheet1 to a thin red border.
Sub SetConditionalFormatBorder()
With Worksheets("Sheet1").Range("B2").FormatConditions(1).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 3
End With
End Sub
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.