Cannot Unhide Module Sheet If Visible Property Is xlVeryHidden

ID: Q153587

The information in this article applies to:

SYMPTOMS

You may not be able to unhide a module sheet if the following two conditions are true:

NOTE: This does not apply to Microsoft Excel 97 for Windows and Microsoft Excel 98 Macintosh Edition; modules in these versions of Microsoft Excel cannot be hidden, since they are displayed in the Visual Basic Editor.

CAUSE

Usually a module sheet that was hidden by setting the Visible property to xlVeryHidden, can be unhidden by setting the Visible property to TRUE. But if the module sheet contains a macro, that is called from a macro in a different module sheet, and that module sheet also contains the macro to unhide the module, the hidden module sheet will not be unhidden.

For example, if a macro named UnhideModule is in a module sheet named, Module1 and the macro below is added to that module sheet (Module1), after the module sheet Module2 is hidden, running the UnhideModule macro will not unhide the Module2 module sheet.

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft Support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

   http://www.microsoft.com/support/supportnet/refguide/default.asp

Type the following code in module sheet, Module1:

   Sub HideModule()
      Sheets("Module2").Visible = xlVeryHidden
   End Sub

   Sub UnhideModule()
      Sheets("Module2").Visible = True
   End Sub

   Sub CallMacroInModule2()
      ' This is a macro in Module1 that calls a macro that is in Module2.
      Call Message ' Message is a macro in Module2.
   End Sub

You will still be able to run all the macros that are contained in the hidden module.

NOTE: If you add the above macro to Module1 before hiding Module2, and then try to hide Module2, you receive an error message.

For additional information, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q131551
   TITLE     : Macro Cannot Set Module to xlVeryHidden

WORKAROUND

To unhide the module sheet, in this example Module2, make sure that the macro that unhides the module sheet (Module2), is in a different module sheet from the macro that calls the macro contained in the hidden module (Module2). Using the example above, you can put the calling macro in a new module sheet, Module3, and leave the unhide macro in Module1. You can also insert an apostrophe before the line that calls the macro, making that line a comment, or delete the calling line. After doing any of the above, you will be able to unhide the module by setting its Visible property to TRUE.

REFERENCES

For more information about the Visible property in Microsoft Excel version 7.0, click Answer Wizard on the Help menu and type:

   Tell me about the visible property

For more information about the Visible property in Microsoft Excel version 5.0, choose the Search button in Help and type:

   visible property

Additional query words: 5.00 5.00a 5.00c 7.00 7.00a XL5 XL7
Keywords          : kbcode kbprg PgmOthr 
Version           : WINDOWS:5.0,5.0c,7.0,7.0a; MACINTOSH:5.0
Platform          : MACINTOSH WINDOWS

Last Reviewed: May 19, 1999