Borders Method

Applies To

Range Object, Style Object.

Description

Accessor. Returns an object that represents a single border (a Border object, Syntax 1) or a collection of borders (a Borders object, Syntax 2). Read-write.

Syntax 1

object.Borders(index)

Syntax 2

object.Borders

object

Required. The Range or Style object.

index

Required for Syntax 1. Specifies the border (one of xlTop, xlBottom, xlLeft, or xlRight).

Example

This example sets the color of the bottom border of cell B2 on Sheet1 to red.


With Worksheets("Sheet1").Range("B2").Borders(xlBottom)
    .LineStyle = xlContinuous
    .ColorIndex = 3
End With

This example sets the color of all four borders of cell B2 on Sheet1 to red.


With Worksheets("Sheet1").Range("B2").Borders
    .LineStyle = xlContinuous
    .ColorIndex = 3
End With