Class Borders (Excel VBA)

A collection of four Border objects that represent the four borders of a Range object or Style object. To use a Borders class variable it first needs to be instantiated, for example


Dim brds as Borders
Set brds = ActiveCell.DisplayFormat.Borders

For Each

Here is an example of processing the Borders items in a collection.


Dim brd As Border
For Each brd In Application.Borders
	
Next brd

Color

Returns or sets the primary color of the object, as shown in the table in the remarks section. Use the RGB function to create a color value.


ActiveCell.DisplayFormat.Borders.Color = RGB(0,0,255)'blue

ColorIndex

Returns or sets a value that represents the color of all four borders. Possible return values are xlColorIndexAutomatic - Automatic color, xlColorIndexNone - No color.

This property returns Null if all four borders aren't the same color. The color is specified as an index value into the current color palette, or as one of the following XlColorIndex constants: xlColorIndexAutomatic or xlColorIndexNone.


ActiveCell.DisplayFormat.Borders.ColorIndex =

Count

Returns a Long value that represents the number of objects in the collection.


Dim lngCount As Long
lngCount = ActiveCell.DisplayFormat.Borders.Count

Item

Returns a Border object that represents one of the borders of either a range of cells or a style.

Item (Index)

Index: Can be one of the XlBordersIndex constants.


Dim brdItem As Border
Set brdItem = ActiveCell.DisplayFormat.Borders(Index:=xlEdgeBottom)

LineStyle

Returns or sets the line style for the border. Read/write XlLineStyle, xlGray25, xlGray50, xlGray75, or xlAutomatic. Possible return values are xlContinuous - Continuous line, xlDash - Dashed line, xlDashDot - Alternating dashes and dots, xlDashDotDot - Dash followed by two dots, xlDot - Dotted line, xlDouble - Double line, xlLineStyleNone - No line, xlSlantDashDot - Slanted dashes.


ActiveCell.DisplayFormat.Borders.LineStyle = xlContinuous

ThemeColor

Returns or sets the theme color in the applied color scheme that is associated with the specified object.

Attempting to access a theme color for an object whose color is not currently themed will result in an invalid request run-time error.


ActiveCell.DisplayFormat.Borders.ThemeColor =

TintAndShade

Returns or sets a Single that lightens or darkens a color.

You can enter a number from -1 (darkest) to 1 (lightest) for the TintAndShade property. Zero (0) is neutral. Attempting to set this property to a value less than -1 or more than 1 results in a run-time error: "The specified value is out of range." This property works for both theme colors and nontheme colors.


ActiveCell.DisplayFormat.Borders.TintAndShade =

Value

Synonym for Borders.LineStyle.


ActiveCell.DisplayFormat.Borders.Value =

Weight

Returns or sets an XlBorderWeight value that represents the weight of the border.


ActiveCell.DisplayFormat.Borders.Weight =