BorderAround Method

         Example         Applies To

Adds a border to a range and sets the Color, LineStyle, and Weight properties for the new border.

Syntax

expression.BorderAround(LineStyle, Weight, ColorIndex, Color)

expression   Required. An expression that returns a Range object.

LineStyle   Optional Variant. The line style for the border. Can be one of the following XlLineStyle constants: xlContinuous, xlDash, xlDashDot, xlDashDotDot, xlDot, xlDouble, xlLineStyleNone, or xlSlantDashDot. The default value is xlContinuous.

Weight   Optional Variant. The border weight. Can be one of the following XlBorderWeight constants: xlHairline, xlThin, xlMedium, or xlThick. The default value is xlThin.

ColorIndex   Optional Variant. The border color, as an index into the current color palette, or as one of the following XlColorIndex constants: xlColorIndexAutomatic or xlColorIndexNone.

Color   Optional Variant. The border color, as an RGB value.

Remarks

You must specify either ColorIndex or Color, but not both.

You can specify either LineStyle or Weight, but not both. If you don't specify either argument, Microsoft Excel uses the default line style and weight.

This method outlines the entire range without filling it in. To set the borders of all the cells, you must set the Color, LineStyle, and Weight properties for the Borders collection. To clear the border, you must set the LineStyle property to xlLineStyleNone for all the cells in the range.