Please Note: This article is written for users of the following Microsoft Excel versions: 2007 and 2010. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Running Macros on Hidden Worksheets.
by Allen Wyatt
(last updated May 5, 2016)
Macros are often used to process information within a workbook. Your macro can access any cells in the workbook, unless the worksheet containing the cell is hidden. When you hide a worksheet, it is even hidden from normal macro operations.
The upshot of this is that if you want to run a macro and have it access information on a hidden worksheet, you must first "unhide" the worksheet. To do this, you use the following line of code in your macro:
Sheets("My Hidden Sheet").Visible = True
When this line is executed, then the worksheet named My Hidden Sheet will no longer be hidden. It is then easily accessible by regular macro commands. When you are later ready to hide the worksheet again (when you are done processing), use this line of code:
Sheets("My Hidden Sheet").Visible = False
Of course, unhiding and later hiding worksheets can cause a lot of flashing on the screen as Excel tries to update its screen display based on the commands executed in your macro. If you want to avoid this, then use the following line of code at the beginning of your macro:
Application.ScreenUpdating = False
With screen updating turned off in this way, nobody will ever know that you unhid a worksheet and later rehid it. Make sure that before ending the macro, however, you set the ScreenUpdating property back to True.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (9329) applies to Microsoft Excel 2007 and 2010. You can find a version of this tip for the older menu interface of Excel here: Running Macros on Hidden Worksheets.
Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!
VBA is a versatile programming language. It is especially good at working with string data. Here are the different VBA ...Discover More
When your macro is humming along, minding its own business, a user watching the screen may not see any activity and ...Discover More
Need to pull a list of words from a range of cells? This tip shows how easy you can perform the task using a macro.Discover More
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.