+ Reply to Thread
Results 1 to 7 of 7

Variable not defined

  1. #1
    Forum Contributor
    Join Date
    12-11-2018
    Location
    Zurich
    MS-Off Ver
    2016
    Posts
    130

    Variable not defined

    Hello,

    I have a userform that populates values from the excel sheet (Tablle 1). Now I would like to be able to click on those values in the userform and the effect on that would be, that these values again show up in the text boxes. However I get an error that the variables are not defined in the following loop:

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Variable not defined

    Put this as 1st line in your code.
    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  3. #3
    Forum Expert Roel Jongman's Avatar
    Join Date
    03-28-2015
    Location
    Netherlands
    MS-Off Ver
    Office 365
    Posts
    1,482

    Re: Variable not defined

    You have put Option Explicit above your code. that means that all variables need to be declared

    So indeed as bakerman2 says put a Dim eighter in the Private sub.

  4. #4
    Forum Contributor
    Join Date
    12-11-2018
    Location
    Zurich
    MS-Off Ver
    2016
    Posts
    130

    Re: Variable not defined

    Problem Solved
    Last edited by travelkid; 01-21-2019 at 06:03 AM.

  5. #5
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Variable not defined

    Because these Textboxes are in a different userform this won't work.
    What exactly are you trying to achieve ?
    Do you want to open the second userform when executing code and filling those TextBoxes.

  6. #6
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Variable not defined

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  7. #7
    Forum Contributor
    Join Date
    12-11-2018
    Location
    Zurich
    MS-Off Ver
    2016
    Posts
    130

    Re: Variable not defined

    Yes, id does take care of the first question. I have a follow up quesiton. So my program now allows me to pick a line in the first userform and show the values on the second userform, where I would like to be able to change these values. How could that be done? Let me know if I should open a new thread instead... Or if thats allowed, probably would get me more answers.

    Best
    Attached Files Attached Files

+ 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. Obect Variable not set error; variable already defined?
    By mrbusto71 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-05-2016, 06:27 PM
  2. Variable Error '1004' - Application-defined or object-defined error
    By christopheralan88 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-01-2015, 12:09 AM
  3. Macro to Insert defined integer into range defined by variable criteria
    By stereofeedback in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-06-2013, 12:33 PM
  4. Variable not defined error when I have defined the variable
    By jeffadkisson in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-27-2012, 07:00 PM
  5. Replies: 3
    Last Post: 09-06-2005, 12:05 PM
  6. Replies: 3
    Last Post: 09-06-2005, 07:05 AM
  7. Replies: 0
    Last Post: 09-06-2005, 01:05 AM

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