Naming modules / macros?

nancyo

Active Member
Joined
Mar 25, 2002
Messages
255
I have a macro which was in an unnamed module in a file (i.e. module 4). I selected the module, F4, and typed in a name for the module.

When I went to tools/macro/macro to list all the macros, it listed the macro name twice
(i.e. NewTC.NewTC). Any idea why this would happen?

I had to go thru my spreadsheets and re-assign all the macro buttons. Am I missing something simple?

BTW, each module only has one macro in it.

Or is it just friday PM...
This message was edited by nancyo on 2002-05-03 13:20
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Maybe you have two macros named NewTC in the same workbook. Renaming the module is not the same as renaming the 'procedure' (macro) in that module. Rename this macro and see what happens (no need to rename the module).

Hope this helps.
 
Upvote 0
It appears that the full name of the macro will include the module name as well when both are named. As long as I know this, I'm OK. I fixed what I need so far this AM, and will remember this from now on. Thanks!!!
 
Upvote 0
Nancy, I don't think that's true, it certainly isn't the case in xl 2000. I still think you have two macros in that workbook with the same name. Better double check.
 
Upvote 0
In Excel97 you can have two macros with the same name. If you run them, the module name will be displayed along with the macro name: module3.test or test.test.

Even though you can do it, it is not a good practice to have macros with the same name.
 
Upvote 0
That's what I'm getting at. The tell tale sign of two macros with the same name. Same w/ 2000. You can run them from the macro dialog but not from the VBE, you'll get an ambiguity error, which I find overrated.

_________________
Cheers,<font size=+2><font color="red"> Nate<font color="blue">O</font></font></font>
wave.gif

This message was edited by NateO on 2002-05-06 12:37
 
Upvote 0
Augh...I will look into this. I checked every single place in the workbook, no duplicate macros that I could find.

Would the macros be considered duplicate if I had two workbooks open, and copied the module from one to the other by clicking and dragging? The, the workbooks are closed, but the name of the macro appears in duplicate,
such as test.test.

Boy, I feel like an idiot. just when i think I understand something...
 
Upvote 0
Nancy, no need to feel like an idiot, you're learning, as we all are. If you have two workbooks open with the a macro in each with the same name, and your macro dialog view is set to all open workbooks, the active workbook's macro will just have a name while the macro in the 2nd workbook will have the workbook's name, and ! preceeding the macro (but no module name).

A quick way to get a handle on the situation is to press alt & f8 (launch macro dialog box), highlight one of the macros, click edit and take note which module this is in. Then do the same with the second. If they're duplicates, delete one, if not, rename one.

Hope this helps.

_________________
Cheers,<font size=+2><font color="red"> Nate<font color="blue">O</font></font></font>
wave.gif

This message was edited by NateO on 2002-05-06 13:59
 
Upvote 0
OK:

1. This AM, I only opened one workbook.

2. There are three macros in the workbook.

3. When I view the codes, they each have a different name (listed in the top, right dropdown box, and at the beginning of the code).

4. When I view the macro dialog box, there are three macros listed. Now, one of them has the double name, as well as the name of the workbook name.

5. This workbook was a copy of another workbook - that is, I opened the other file, and "saved as" with the new name. Would this have anything to do with it? How do I rename a macro?

6. I am going to look into this some more, but I am SO frustrated, I can barely stand it. This is the macro which finally works (excel to excel).
 
Upvote 0
Nancy, to get rid of the "double name", change the name of the module back to Module1 or whatever number you would like. For some reason, Excel will ignore the module name if it is named Module with a number.
 
Upvote 0

Forum statistics

Threads
1,213,559
Messages
6,114,302
Members
448,564
Latest member
ED38

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