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…  :)

Advertisements
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

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s