Alwyn Miranda
Alwyn Miranda

Reputation: 370

Macro visibility in other excel sheets

I created the macro in one of the excel workbook (abc.xlsm). And I want only that particular workbook to display the macros in view macros popup. But when view macros from other workbook (xyz.xlsx) I am able to view the macros which I created in the abc.xlsm. I tried with private keyword before the macro. But it will hide the macro visibility in all the workbooks including the first workbook (abc.xlsm) IS THERE ANYWAY TO RESTRICT THE MACRO VISIBILITY ONLY IN THE WORKBOOK WHICH IT WAS CREATED?

Upvotes: 0

Views: 241

Answers (1)

Max Segal
Max Segal

Reputation: 2045

Excel macros popup lists all the macros available for execution in all workbooks that are open in the current Excel instance. This means that the only option to execute the macro only from a specific workbook is to check if ActiveWorkbook is the workbook you want the macro to be executed from. You can accomplish that with this line on top of your sub code:

If Not ActiveWorkbook.Name = "abc.xlsm" Then Exit Sub

Upvotes: 1

Related Questions