+ Reply to Thread
Results 1 to 4 of 4

VBA code doesn't remember data

  1. #1
    Registered User
    Join Date
    08-16-2012
    Location
    Almere
    MS-Off Ver
    Excel 2003
    Posts
    48

    VBA code doesn't remember data

    I have a simple userform where a variable named X is set, depending on a combobox, as seen below..
    Please Login or Register  to view this content.
    it's not the whole code but just to see what is needed. When a user selects 'Order' from the combobox, variable X should be a specific website.
    It works because a messagebox is shown with the correct website.

    Now I also have a Button in the userform and when this button is pressed, it should open the website (X) in a new window, but this doesn't work...
    the code for the button is:
    Please Login or Register  to view this content.
    However, the variable X is no longer filled with the website address !

    I think it's because I used the End Sub and start a new Sub but I'm not sure how to do the trick so the website opens when the button is pressed

  2. #2
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: VBA code doesn't remember data

    hi minifreak, option:

    Please Login or Register  to view this content.

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: VBA code doesn't remember data

    Put this at the very top of the code module above all the procedures.

    Dim X as String

    This will declare the variable X and it will be accessible to the other procedures within the code module.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  4. #4
    Registered User
    Join Date
    08-16-2012
    Location
    Almere
    MS-Off Ver
    Excel 2003
    Posts
    48

    Re: VBA code doesn't remember data

    @watersev, Your option worked, I tried it before but I wanted to set the variable earlier when and I knew it had to be something with Dim As...
    @ AlphaFrog, I put the Dim As function like you mentioned at the top of the code and now it worked !!!
    Earlier I had the same line of code but inside the Private Sub ...... End Sub and this didn't work.
    Now I'm just glad that I can continue with the code

+ 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. Text Box code doesn't work when other combo box is provided by a data
    By agonysWeeper in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-08-2013, 05:42 AM
  2. [SOLVED] Checkbox to remember data
    By minifreak in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-30-2012, 05:37 AM
  3. VBA code doesn't run after a while
    By tffkab in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 04-26-2011, 03:45 PM
  4. Code to scrape system generated outlook email doesn't get all the data
    By bobaftt in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-15-2010, 01:57 PM
  5. Code ran, now it doesn't
    By davegb in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-31-2005, 07: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