Borders Collection

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.


Aa612950.parchild(en-us,office.10).gifBorders
Aa612950.space(en-us,office.10).gifAa612950.parchild(en-us,office.10).gifBorder

A collection of four Border objects that represent the four borders of a Range or Style object.

Using the Borders Collection

Use the Borders property to return the Borders collection, which contains all four borders. The following example adds a double border to cell A1 on worksheet one.

  Worksheets(1).Range("A1").Borders.LineStyle = xlDouble

Use Borders(index), where index identifies the border, to return a single Border object. The following example sets the color of the bottom border of cells A1:G1 to red.

  Worksheets("Sheet1").Range("A1:G1"). _
    Borders(xlEdgeBottom).Color = RGB(255, 0, 0)

Index can be one of the following XlBordersIndex constants: xlDiagonalDown, xlDiagonalUp, xlEdgeBottom, xlEdgeLeft, xlEdgeRight, or xlEdgeTop, xlInsideHorizontal, or xlInsideVertical.

Remarks

You can set border properties for an individual border only with Range and Style objects. Other bordered objects, such as check boxes and chart areas, have a border that’s treated as a single entity, regardless of how many sides it has. For these objects, you must return and set properties for the entire border as a unit. For more information, see the Border object.