+ Reply to Thread
Results 1 to 6 of 6

Clearing undefined variable [Excel 14/2010] (VBA Only)

  1. #1
    Forum Contributor
    Join Date
    03-22-2012
    Location
    OR, USA
    MS-Off Ver
    Excel 14/2010
    Posts
    273

    Clearing undefined variable [Excel 14/2010] (VBA Only)

    Say I am using the following in the first macro. Once the macro is completed, I use a 2nd macro to clear the fields on the spreadsheet to reuse it using the first macro. Is there a way to clear out the variables globally so that macro can run cleanly? Without using each of the variable names (as they vary from sheet to sheet) since the 2nd macro clears out many other spreadsheets?

    Please Login or Register  to view this content.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Where are these variables declared?
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    03-22-2012
    Location
    OR, USA
    MS-Off Ver
    Excel 14/2010
    Posts
    273

    Re: Clearing undefined variable [Excel 14/2010] (VBA Only)

    These variables are defined in the first macro. Separate spreadsheets will have different variables.
    The 2nd macro that resets the spreadsheets is an add-in. This is where I want to clear the variables from the various spreadsheets.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Clearing undefined variable [Excel 14/2010] (VBA Only)

    If these variables have been declared within a sub then they aren't visible to any other subs.

  5. #5
    Forum Contributor
    Join Date
    03-22-2012
    Location
    OR, USA
    MS-Off Ver
    Excel 14/2010
    Posts
    273

    Re: Clearing undefined variable [Excel 14/2010] (VBA Only)

    Maybe I am asking the wrong question. When the variables are declared Excel sets aside memory. Is there a way to globally clear out the memory?

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Clearing undefined variable [Excel 14/2010] (VBA Only)

    That memory is released as soon as the sub ends.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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