Class ColorStop (Excel VBA)

The class ColorStop represents the color stop point for a gradient fill in a range or selection.

Item

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

Dim cstp as ColorStop
Set cstp = ActiveCell.Interior.Gradient.ColorStops(Index:=1)

The following procedures can be used to set variables of type ColorStop: ColorStops.Add and ColorStops.Item.

For Each

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

Dim cstp As ColorStop
For Each cstp In ActiveCell.Interior.Gradient.ColorStops
	
Next cstp

Color

Returns or sets the color of the represented object.

ActiveCell.Interior.Gradient.ColorStops(1).Color =

Delete

Deletes the represented object.

ActiveCell.Interior.Gradient.ColorStops(1).Delete

Position

Returns or sets the position of the ColorStop.

ActiveCell.Interior.Gradient.ColorStops(1).Position =

ThemeColor

Returns or sets the theme color of the represented object.

Range("A1:A10").Select 
With Selection.Interior.Gradient.ColorStop.Add(1) 
 .ThemeColor = xlThemeColorAccent1 
 .TintAndShade = 0 
End With

TintAndShade

Returns or sets the tint and shade of the represented object. Read/write

ColorStops.Add

Adds a ColorStop object to the specified collection.

Add (Position)

Position: Represents the position in which to apply the ColorStop.

With Range("A1:A10").Interior.Gradient.ColorStop.Add(1) 
 .ThemeColor = xlThemeColorAccent1 
 .TintAndShade = 0 
End With

ColorStops.Clear

Clears the represented object.

ActiveCell.Interior.Gradient.ColorStops.Clear

ColorStops.Count

Returns or sets the count of the represented object.

Dim lngCount As Long
lngCount = ActiveCell.Interior.Gradient.ColorStops.Count

ColorStops.Item

Returns a single object from the represented collection.

Item (Index)

Index: The name or index number for the object.

Dim cstp As ColorStop
Set cstp = ActiveCell.Interior.Gradient.ColorStops(Index:=1)