Please Note:
This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Counting the Times a Worksheet is Used.

Counting the Times a Worksheet is Used

You may want a way to keep track of how many times a particular worksheet is used. There are many ways you can accomplish this. One simple way is to just store the count in the worksheet itself. Right-click a worksheet tab, then choose View Code from the Context menu. Excel displays the Visual Basic Editor, where you should paste the following code:

This function is designed to be called from a different macro—one triggered by the event that should cause the usage counter to increment. For instance, if you want to keep track of every time the worksheet is activated, then you would use the following macro as part of the ThisWorkbook object:

The macro increments a counter named "Activated" for the worksheet. It does this by calling the IncrementEventCounter macro, with the name of the counter and the name of the worksheet. If, instead, you wanted to count the number of times that a worksheet was changed, you could use the following macro as part of the ThisWorkbook object:

The only difference between this macro and the previous one is that it increments a counter named "Changed." To see the values of the counters, just enter a formula in a cell that references the counter. For instance, you could enter =Changed to see the value of the Changed counter, or =Activated to see the value of the Activated counter. The value of each counter will differ from sheet to sheet, since the counters are maintained on a sheet-by-sheet basis.

ExcelTips is your source for cost-effective Microsoft Excel training.
This tip (2497) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Counting the Times a Worksheet is Used.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. Learn more about Allen...

MORE FROM ALLEN

Automatically Creating Charts for Individual Rows in a Data Table

If you have a lot of records in a data table, you may want to create individual charts based on the information in those ...

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More ExcelTips (menu)

Deleting Names

Excel allows you to associate names with cells or ranges of cells. If you ever want to delete those names, you'll need ...

Comments

If you would like to add an image to
your comment (not an avatar, but an image to help in making the point of your comment),
include the characters [{fig}] in your comment text. You’ll be prompted to upload
your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will
be reduced. Up to three images may be included in a comment. All images are subject to
review. Commenting privileges may be curtailed if inappropriate images are posted.

Source

(gif, jpeg or png only, 5MB maximum file size)

Source

(gif, jpeg or png only, 5MB maximum file size)

Source

(gif, jpeg or png only, 5MB maximum file size)

Notify me about new comments ONLY FOR THIS TIP

Notify me about new comments ANYWHERE ON THIS SITE

Hide my email address

What is six more than 8?

There are currently no comments for this tip. (Be the first to leave your comment—just use
the simple form above!)