Issue with macro names

sparky2205

Active Member
Joined
Feb 6, 2013
Messages
480
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have a number of macros on a worksheet which I have added to the context menu. No problem, they all work fine.
I have now added 2 more macros which appear without issue on the context menu.
The problem: when I click on the macro name in the context menu it can't find the macro.
I've found the problem but I don't understand why it is happening.
My macro name is MoveSheet. When I look at the macros in my worksheet I can see that this macro is called CopySheet.CopySheet. Adding this macro name to the context menu setup, it works fine.
All my existing macros, which work fine, are called; CopySheet, DeleteSheet, RenameSheet etc.
I'm wondering why newly added macros, MoveSheet & ColourTab would be called MoveSheet.MoveSheet & ColourTab.ColourTab.
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Are your module names the same as your SUB name? I've noticed problems when I have Module names, sheet names, code names, Sub names, or Function names the same as any of the others
 
Upvote 0
Solution
Hi Jeffrey,
yes, the module and sub names are the same and I have seen issues with this myself previously so I usually avoid doing this.
These are older macros that I created a few years back before I was aware of that.
I did try changing the module names so that they differ from the sub names but it didn't appear to sort the issue.
However, I will revisit this as I now know that the macros work fine when assigned to a button. The difference being, of course, that I select the macro from a list rather then typing the name into the vbe to assign to the context menu.
I will look at this again in the morning and return here with an update.
 
Upvote 0
Good morning Jeffrey,
this now works after changing the sub name to be different to the module name.
Interestingly it didn't work when I changed the module name.
Thanks for putting me back on the track I had wandered off.
Enjoy your weekend.
 
Upvote 0

Forum statistics

Threads
1,215,068
Messages
6,122,950
Members
449,095
Latest member
nmaske

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top