+ Reply to Thread
Results 1 to 2 of 2

Public variables keep forgetting set value

  1. #1
    Registered User
    Join Date
    05-19-2016
    Location
    uk
    MS-Off Ver
    2010
    Posts
    18

    Angry Public variables keep forgetting set value

    This one has been annoying me for a little bit now, and i hate the idea of having to try and do it by passing values to hidden cells to retrieve later, it should be possible completely from within the VBA module.

    so here's the objective.... open excel, change a whole heap of settings to what i want, from excel general settings to workbook specific ones, that part is easy, returning the users default settings on close is proving less easy

    I've got a module with all of my public declarations and functions in, so all of my values are Dim'd as Public and in the correct reference, be it Boolean or String etc etc

    On opening the workbook, a good number of things are called and run, from within the workbook_open event, high up on the list are all of those settings defaults stored to the various variables for save keeping, or so i thought!
    The workbook is not simple by any means, and has a large number of things going on with macros and objects and user forms

    Upon close, all of the altered settings are supposed to be reset to the stored defaults, but, the dam variables keep dropping their values.


    Now i know, i can flip all the values to a hidden worksheet, and then load them back at close, but, it's not very elegant, and to be quite honest, this "forgetting of data" by the declared variables is annoying as hell, so, is there a way to fix this ?

  2. #2
    Registered User
    Join Date
    05-19-2016
    Location
    uk
    MS-Off Ver
    2010
    Posts
    18

    Re: Public variables keep forgetting set value

    ok, so it seems that even if you declare it Public in scope in a code module, ANY run-time error will set it to null, causing the values to be lost, not sure if this includes any errors that you might have skipped using on error resume next, or just untrapped errors, but, as i have been working on and testing this workbook, i've triggered a lot of errors, making this likely to be my main culprit


    I think i might have to take the annoying steps to save the data to a second worksheet to import it later

+ 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] Public variables
    By kosherboy in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-16-2015, 04:25 PM
  2. [SOLVED] Public Variables
    By iamGreenhorn in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-21-2014, 12:38 PM
  3. Public variables
    By Tomski in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-10-2006, 10:20 AM
  4. Public Variables
    By [email protected] in forum Excel General
    Replies: 6
    Last Post: 09-12-2005, 12:05 PM
  5. Public Variables
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-01-2005, 12:05 PM
  6. [SOLVED] Public Variables
    By ExcelMonkey in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-21-2005, 07:06 AM
  7. Public variables
    By jcp29 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-02-2005, 07:10 PM

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