+ Reply to Thread
Results 1 to 9 of 9

Variable not defined error

  1. #1
    Registered User
    Join Date
    12-05-2010
    Location
    LA, CA
    MS-Off Ver
    Excel 2010
    Posts
    59

    Variable not defined error

    Hi,
    I copied code from another sheet into my own and I keep getting a variable not defined on "Listbox1" I'm not sure why. Can someone help me? Here is the code:

    Please Login or Register  to view this content.
    Last edited by janeml; 07-07-2013 at 07:36 PM.

  2. #2
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Variable not defined error

    It means that you don't have an object named "Listbox1". You need to change it the real name of the listbox you are using.
    Please consider:

    Thanking those who helped you. Click the star icon in the lower left part of the contributor's post and add Reputation.
    Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.

  3. #3
    Registered User
    Join Date
    12-05-2010
    Location
    LA, CA
    MS-Off Ver
    Excel 2010
    Posts
    59

    Re: Variable not defined error

    Plan_Sample.xlsm

    I did change the object name to Listbox1, and I'm still getting the same error.

    I've attached a copy of the worksheet.

    Essentially, the Populate List Box button is suppose to populate the box w/ checkbox options for users to select what variables they have to have appear on the graph. I was also wondering if it's possible to have a macro that unchecks everything so the user wont have to uncheck one by one.

    Thanks!

  4. #4
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Variable not defined error

    Since the listbox is in a worksheet and you are running code from a standard module, you have to tell Excel where to find the listbox. Therefore a simple modification is needed:

    Please Login or Register  to view this content.
    EDIT : Here you will find code to uncheck all the choices.

    abousetta
    Last edited by abousetta; 07-07-2013 at 07:05 PM.

  5. #5
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Variable not defined error

    Did the file you copied this from have a userform?
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  6. #6
    Registered User
    Join Date
    12-05-2010
    Location
    LA, CA
    MS-Off Ver
    Excel 2010
    Posts
    59

    Re: Variable not defined error

    Hi Solus, yes it did.

  7. #7
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Variable not defined error

    You will need that userform. It seems to have the listbox and all the option buttons. These macros won't work without them.

    You will have to recreate the userform in the new workbook.

  8. #8
    Registered User
    Join Date
    12-05-2010
    Location
    LA, CA
    MS-Off Ver
    Excel 2010
    Posts
    59

    Re: Variable not defined error

    somehow...I got it to work within the workbook. Thank you Abousetta and Solus!

  9. #9
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Variable not defined error

    Thanks for the feedback.

    Good luck.

    abousetta

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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