+ Reply to Thread
Results 1 to 4 of 4

Public strings keeping values after a macro is completed

  1. #1
    Registered User
    Join Date
    09-13-2012
    Location
    Karachi
    MS-Off Ver
    Excel 2010
    Posts
    18

    Public strings keeping values after a macro is completed

    Hello everyone!

    I am having issues with a few of my public variables that are keeping the values of that were stored in them in the last run (Excel wasn't closed).

    How do I reset the values, without having to do s_Test1 = "" for each string?

    Here is an example, If I run this macro two times, it keeps the values form the first run and shows x2 values in the second run:

    Please Login or Register  to view this content.

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Public strings keeping values after a macro is completed

    Why not declare them in the sub?

  3. #3
    Registered User
    Join Date
    09-13-2012
    Location
    Karachi
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Public strings keeping values after a macro is completed

    Quote Originally Posted by Kyle123 View Post
    Why not declare them in the sub?
    The reason I am not declaring them within a sub is that I have multiple subs where I am using these values.

  4. #4
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Public strings keeping values after a macro is completed

    Then either pass them as parameters or clear the values at the end of the sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Adding Numbers As Strings And Keeping Format
    By ejoneslor in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-24-2016, 07:13 AM
  2. Macro to Delete only Alpha Strings but not Alphanumeric or Numeric Strings in a Cell
    By papageorgio in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-19-2016, 06:55 AM
  3. Value of Public Constant From Concatenate strings
    By exceere in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-13-2014, 04:45 PM
  4. [SOLVED] Public variable values??
    By Needhelp!!! in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-26-2013, 08:30 AM
  5. Matching Strings in two columns and keeping the data that matches
    By camdenl08 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-26-2013, 01:15 AM
  6. Replies: 1
    Last Post: 02-14-2011, 04:59 PM
  7. Keeping track of unique strings in a column
    By praame in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-05-2007, 05:28 AM

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