Cannot Edit a Macro on a Hidden Workbook – 2 Solutions

While trying to edit a Macro, a notification box is displayed:

Cannot Edit a Macro on a Hidden Workbook in Excel

The Macro is not in the active workbook, it’s in a different workbook that is hidden (PERSONAL.xlsb here).


Solution 1 – Editing a Macro on a Hidden Workbook by Unhiding It 

Step 1: Opening the Unhide Dialog Box in the View Tab

  • Go to the View tab.
  • In Windows, click Unhide.

Unhiding Workbook to Solve Cannot Edit a Macro on a Hidden Workbook

Step 2: Unhiding the Workbook in the Dialog Box

  • In the Unhide dialog box, select the hidden workbook (PERSONAL.xlsb).
  • Click OK.

Step 3: Editing the Macro

To edit the Macro:

  • Go to the Developer tab.
  • Click Macros in Code.

Editing the Macro to Solve Cannot Edit a Macro on a Hidden Workbook

  • Select your Macro and click Edit.

Editing a Macro to solve cannot edit a Macro on a hidden workbook

You can edit it.

Read  More: [Fixed!]: Unable to Enable Macros in Excel


Solution 2 – Editing a Macro in a Hidden Workbook Using a VBA Code

VBA Code:

Sub Edit_a_Macro_on_a_Hidden_Workbook()

Hidden_Workbook_Name = "PERSONAL.XLSB"
Hidden_Macro_Name = "Macro1"
Active_Workbook_Name = "Cannot Edit a Macro on a Hidden Workbook.xlsm"

Windows(Hidden_Workbook_Name).Visible = True
Windows(Active_Workbook_Name).Activate
Application.Goto Reference:=Hidden_Workbook_Name + "!" + Hidden_Macro_Name

End Sub

VBA Code to Solve Cannot Edit a Macro on a Hidden Workbook

 Notes:

The hidden workbook is “PERSONAL.XLSB”, the hidden Macro is “Macro1”, and the workbook is “Cannot Edit a Macro on a Hidden Workbook.xlsm” (here).

Inputs to the Code to Solve Cannot Edit a Macro on a Hidden Workbook

Output:

  • Run the code by clicking Run Sub / UserForm.

The workbook will be unhidden and the editor window will be displayed.

 


Download Practice Workbook

Download the practice workbook.


Related Articles

Get FREE Advanced Excel Exercises with Solutions!
Rifat Hassan
Rifat Hassan

Rifat Hassan, BSc, Electrical and Electronic Engineering, Bangladesh University of Engineering and Technology, has worked with the ExcelDemy project for almost 2 years. Within these 2 years, he has written over 250 articles. He has also conducted a few Boot Camp sessions on effective coding, especially Visual Basic for Applications (VBA). Currently, he is working as a Software Developer to develop and deploy additional add-ins to enhance the customers with a more sophisticated experience with Microsoft Office Suits,... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo