+ Reply to Thread
Results 1 to 2 of 2

Maintain Variable Value when calling a new macro

  1. #1
    Registered User
    Join Date
    12-04-2009
    Location
    Portland, Oregon
    MS-Off Ver
    Excel 2003
    Posts
    3

    Maintain Variable Value when calling a new macro

    I have set up am array to select specific cells based in the value of variable X, which works just fine. As I am going to be using this code several times I would prefer to use the call function for this in the middle of a loop. The problem is when I call the new macro, X gets reset to 0.

  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile Re: Maintain Variable Value when calling a new macro

    Good evening guinness4breakfast
    Quote Originally Posted by guinness4breakfast View Post
    The problem is when I call the new macro, X gets reset to 0.
    There are a couple of ways of handling this, depending on how your macros are set up. If both macros are in the same module, then just declare the variables you want sharing outside both of them, thus :
    Please Login or Register  to view this content.
    Run the macro "test" to see it work.

    HTH

    DominicB
    Please familiarise yourself with the rules before posting. You can find them here.

+ 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