Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Returns a Borders collection that represents the borders of a conditional format.
Syntax
expression.Borders
expression A variable that represents a FormatCondition object.
Remarks
The Borders collection returned by a FormatCondition uses the conditional-format side constants xlLeft, xlRight, xlTop, and xlBottom.
Don't use xlEdgeLeft, xlEdgeRight, xlEdgeTop, xlEdgeBottom, xlInsideHorizontal, or xlInsideVertical with this collection. Those constants apply to Range.Borders. Using an xlEdge index with FormatCondition.Borders can cause run-time error 1004 (COM error 0x800A03EC) when you access properties such as LineStyle or Weight.
You can read or write the LineStyle, Weight, and color properties when you select a supported conditional-format side. For the supported line styles and weights, see the FormatCondition object.
Example
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(xlBottom)
.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.