Adding Metadata to a Worksheet:CustomProperties

Posted: July 29, 2013 by kulshresthazone in Excel, VBA
Tags:

Want to keep some information a bit out of reach of the user or you want to keep some information for your code support, away from general user.

One way of storing information is using constants in your code. Now, suppose you have multiple sheets and you want to associate the constant’s values with specific sheets. Then, in place of creating a mapping of sorts or creating multiple constants for each sheet, you can make use of adding metadata to a worksheet.
To Add:

Worksheets(WorksheetName).CustomProperties.Add Name:=PropertyName, Value:= SomeValue

To Read:

Worksheets(WorksheetName).CustomProperties.Item(PropertyIndex).Value

Happy Coding…  :)

Comments
  1. I wish I had knewn about this a year ago, it would have saved me time creating my own mapping logic in a hidden worksheet. Thanks for sharing.

Share your thoughts/feedback