Class Border (Excel VBA)

The class Border represents the border of an object. To use a Border class variable it first needs to be instantiated, for example


Dim brd as Border
Set brd = ActiveCell.BorderAround()

For Each

Here is an example of processing the Border 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.BorderAround.Color = RGB(0,0,255)'blue

ColorIndex

Returns or sets a value that represents the color of the border. Possible return values are xlColorIndexAutomatic - Automatic color, xlColorIndexNone - No 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.BorderAround.ColorIndex = xlColorIndexAutomatic

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.

xlDouble and xlSlantDashDot do not apply to charts.


ActiveCell.BorderAround.LineStyle = xlContinuous

ThemeColor

Returns or sets the theme color in the applied color scheme that is associated with the specified object. Here you can find possible values for XlThemeColor.

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.BorderAround.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 this run-time error: "The specified value is out of range." This property works for both theme colors and nontheme colors.


ActiveCell.BorderAround.TintAndShade =

Weight

Returns or sets an XlBorderWeight value that represents the weight of the border. Possible return values are xlHairline - Hairline (thinnest border), xlMedium - Medium, xlThick - Thick (widest border), xlThin - Thin.


ActiveCell.BorderAround.Weight = xlMedium