Class CustomProperty (Excel VBA)

The class CustomProperty represents identifier information, which can be used as metadata for XML.


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

Dim cprp as CustomProperty
Set cprp = ActiveSheet.CustomProperties(Index:=1)

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

For Each

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

Dim cprpCustomPropertie As CustomProperty
For Each cprpCustomPropertie In ActiveSheet.CustomProperties
Next cprpCustomPropertie


Adds custom property information.

Add (Name, Value)

Dim strName As String: strName = 
Dim cprp As CustomProperty
Set cprp = ActiveSheet.CustomProperties.Add(Name:=strName, Value:=)


The following arguments are required:

Name (String) - The name of the custom property.

Value - The value of the custom property


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

Dim lngCount As Long
lngCount = ActiveSheet.CustomProperties.Count


Returns a single object from a collection.

Item (Index)

Index: The index number of the object.

Dim cprpItem As CustomProperty
Set cprpItem = ActiveSheet.CustomProperties(Index:=1)


Deletes the object.

You can delete custom document properties, but you cannot delete a built-in document property.



Returns or sets a String value representing the name of the object.

ActiveSheet.CustomProperties(1).Name =


Synonym for the Borders.LineStyle property.

ActiveSheet.CustomProperties(1).Value =