+ Reply to Thread
Results 1 to 3 of 3

Excel VBA 2010 - Problems with Variables - Option Explicit/Public

  1. #1
    Registered User
    Join Date
    11-26-2015
    Location
    Tampa, FL - US
    MS-Off Ver
    Excel 2010
    Posts
    33

    Excel VBA 2010 - Problems with Variables - Option Explicit/Public

    I'm in the process of a new program. My problem is that I'm trying to write so that a user is prompted one time (at set-up) for a variable - a path. After that they should never have to state it again. What I am experiencing using Option Explicit/ Public is that when I close and open the spreadsheet, it looses the variable and I have to re-do the 'one time only' InputBox. What am I doing wrong? I'm totally new at this... Thanks in advance.

    Please Login or Register  to view this content.
    If when I open the spreadsheet, I get prompted that it can't find the word doc. However, if I run the InputBox and put in the path variable, it will run fine until it crashes somewhere else. Is there a way to keep that variable in there 'forever'? So that when they close and open the program they don't have to keep using the InputBox? Thanks folks... Look forward to hearing from you.

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

    Re: Excel VBA 2010 - Problems with Variables - Option Explicit/Public

    All variables will be destroyed when you close the workbook.

    If you want to keep the value you'll need to store it somewhere.

    Then the next time you open the workbook you can check if there is a stored value.

    If there is you can set the variable to that value, if there isn't you can prompt the user for the value.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    11-26-2015
    Location
    Tampa, FL - US
    MS-Off Ver
    Excel 2010
    Posts
    33

    Re: Excel VBA 2010 - Problems with Variables - Option Explicit/Public

    Thank you for a solution - simple and easy. What do you think would be best used? Some type of if then upon opening, like an auto-open or upon initializing?

    Thanks again.

+ 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] Excel VBA 2010 - Is it possible to have an input box write an Option Explicit?
    By b4tmast in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-01-2015, 10:58 PM
  2. Dim in Option Explicit
    By narrowgate88 in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 03-22-2011, 03:47 PM
  3. Option Explicit and Dim ds as what?
    By leaning in forum Excel General
    Replies: 3
    Last Post: 10-20-2010, 03:50 PM
  4. Option Explicit function and private/public/dim
    By larryg003 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-09-2010, 03:01 PM
  5. variables:Option Explicit
    By snakeman11689 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-15-2008, 02:03 PM
  6. [SOLVED] Option explicit
    By Alexandre Brisebois (www.pointnetsolutions.com) in forum Excel General
    Replies: 1
    Last Post: 07-25-2005, 12:05 PM

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