Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Naming modules / macros?

  1. #1
    Board Regular
    Join Date
    Mar 2002
    Location
    Massachusetts, USA
    Posts
    255
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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 ]

  2. #2
    Legend NateO's Avatar
    Join Date
    Feb 2002
    Location
    Minneapolis, Mn, USA
    Posts
    9,700
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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.

  3. #3
    Board Regular
    Join Date
    Mar 2002
    Location
    Massachusetts, USA
    Posts
    255
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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!!!

  4. #4
    Legend NateO's Avatar
    Join Date
    Feb 2002
    Location
    Minneapolis, Mn, USA
    Posts
    9,700
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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.

  5. #5
    Board Regular
    Join Date
    Apr 2002
    Location
    Minnesota
    Posts
    821
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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.


  6. #6
    Legend NateO's Avatar
    Join Date
    Feb 2002
    Location
    Minneapolis, Mn, USA
    Posts
    9,700
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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, NateO

    [ This Message was edited by: NateO on 2002-05-06 12:37 ]

  7. #7
    Board Regular
    Join Date
    Mar 2002
    Location
    Massachusetts, USA
    Posts
    255
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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...

  8. #8
    Legend NateO's Avatar
    Join Date
    Feb 2002
    Location
    Minneapolis, Mn, USA
    Posts
    9,700
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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, NateO

    [ This Message was edited by: NateO on 2002-05-06 13:59 ]

  9. #9
    Board Regular
    Join Date
    Mar 2002
    Location
    Massachusetts, USA
    Posts
    255
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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).

  10. #10
    Board Regular
    Join Date
    Apr 2002
    Location
    Minnesota
    Posts
    821
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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.

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •