+ Reply to Thread
Results 1 to 10 of 10

Macros name changing.

  1. #1
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Macros name changing.

    Hi all,
    I have a problem with how Excel is naming my macros. For the most part, the name that I enter is used. For instance:

    I have many provincial updates with the following naming schemes.
    MBCPI
    BCCPI
    ....
    The problem is, I have a line now that says this:
    CopyCPI.xls!ProvCPIUpdate.ProvCPIUpdate
    It should only read: ProvCPIUpdate because that is the name that I named it.
    Any ideas?

    Thanks.
    Last edited by Mordred; 08-10-2010 at 11:24 AM.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  2. #2
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Macros name changing.

    It depends on what is the active workbook. If you have two or more workbook open, it will list all the available macros, but will add on the workbook and module name to identify the source. If you only have the workbook with the macro desired open, it will display as you named it.

  3. #3
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Macros name changing.

    Thanks Whizbang, I've noticed that when there is more than one workbook open but I only have one open, and the macro belongs to it. Mayhap it is some sort of glitch in Excel? Plus, I only see it named that way on the list that comes up when I click on the run button from the macros toolbar.

  4. #4
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Macros name changing.

    Do you have any macros saved in your personal.xls workbook? Maybe that is what is causing it to rename.

    **Edit**

    I just ran a test. Please disregard all of my mis-informed posts. It is renaming it for me as well. Huh. I never noticed that.

  5. #5
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Macros name changing.

    I found this link, which says that it is just the way it is.

    http://answers.yahoo.com/question/in...5214231AAnFUDh

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,968

    Re: Macros name changing.

    Re CopyCPI.xls!ProvCPIUpdate.ProvCPIUpdate
    That means you have put the macro named ProvCPIUpdate into a module also named ProvCPIUpdate. You should NEVER do that.
    Everyone who confuses correlation and causation ends up dead.

  7. #7
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Macros name changing.

    I totally understand the logic if there are more than one macro with the same name but I haven't created another macro with that specific name. Oh well, it doesn't change how the program is run, it is a pain however if I use that particular sub in another sub because I have to call it by its display name instead of just ProvCPIUpdate. Thanks Whizbang.

  8. #8
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Macros name changing.

    Hi romperstomper, I haven't done that though, this is my sub:

    Please Login or Register  to view this content.

  9. #9
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Macros name changing.

    No, what he is saying is that you created a module called "ProvCPIUpdate" and then within that module you created a subroutine called "ProvCPIUpdate". This is not the recommended practice.

    Also, you CAN call the sub by the name ProvCPIUpdate, as long as the sub is not private to the module.

    For instance, put this code in another module in the workbook and then run it.

    Please Login or Register  to view this content.

  10. #10
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Macros name changing.

    Thanks Whizbang and romperstomper, you two nailed it. My module and sub were named the same. I renamed my module and now its all good.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1