Class Border (Excel VBA)

The class Border represents the border of an object.

Set

To use a Border class variable it first needs to be instantiated, for example

Dim aae As AboveAverage: Set aae = 
Dim brdBorder As Border
Set brdBorder = aae.Borders(Index:=xlDiagonalDown)

The following procedures can be used to set variables of type Border: Axis.Border, Borders.Item, DataTable.Border, DropLines.Border, ErrorBars.Border, Gridlines.Border, HiLoLines.Border, LeaderLines.Border, OLEObject.Border, OLEObjects.Border, Range.BorderAround, SeriesLines.Border, Trendline.Border, AboveAverage.Borders, DisplayFormat.Borders, FormatCondition.Borders, Range.Borders, Style.Borders, TableStyleElement.Borders, Top10.Borders and UniqueValues.Borders

For Each

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

Dim aae As AboveAverage: Set aae = 
Dim brdBorder As Border
For Each brdBorder In aae.Borders
	
Next brdBorder

Properties

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.

Charts("Chart1").Axes(xlValue).TickLabels.Font.Color = _ 
 RGB(0, 255, 0)

ColorIndex returns or sets a value that represents the color of the border.

With Charts("Chart1").Axes(xlValue) 
 If .HasMajorGridlines Then 
 .MajorGridlines.Border.ColorIndex = 5 'set color to blue 
 End If 
End With

LineStyle returns or sets the line style for the border. Read/write XlLineStyle, xlGray25, xlGray50, xlGray75, or xlAutomatic.

With Charts("Chart1") 
 .ChartArea.Border.LineStyle = xlDashDot 
 With .PlotArea.Border 
 .LineStyle = xlDashDotDot 
 .Weight = xlThick 
 End With 
End With

Parent returns the parent object for the specified object. Read-only.

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

TintAndShade returns or sets a Single that lightens or darkens a color.

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

Worksheets("Sheet1").Ovals(1).Border.Weight = xlMedium

Borders.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.

Charts("Chart1").Axes(xlValue).TickLabels.Font.Color = _ 
 RGB(0, 255, 0)

Borders.ColorIndex returns or sets a value that represents the color of all four borders.

Borders.Count returns a Long value that represents the number of objects in the collection.

Borders.Item returns a Border object that represents one of the borders of either a range of cells or a style.

Worksheets("Sheet1").Range("a1:g1"). _ 
 Borders.Item(xlEdgeBottom).Color = RGB(255, 0, 0)

Borders.LineStyle returns or sets the line style for the border. Read/write XlLineStyle, xlGray25, xlGray50, xlGray75, or xlAutomatic.

With Charts("Chart1") 
 .ChartArea.Border.LineStyle = xlDashDot 
 With .PlotArea.Border 
 .LineStyle = xlDashDotDot 
 .Weight = xlThick 
 End With 
End With

Borders.Parent returns the parent object for the specified object. Read-only.

Borders.ThemeColor returns or sets the theme color in the applied color scheme that is associated with the specified object.

Borders.TintAndShade returns or sets a Single that lightens or darkens a color.

Borders.Value synonym for Borders.LineStyle.

Borders.Weight returns or sets an XlBorderWeight value that represents the weight of the border.