+ Reply to Thread
Results 1 to 13 of 13

Problems adding items to listbox

  1. #1
    Registered User
    Join Date
    06-07-2012
    Location
    Michigan
    MS-Off Ver
    Excel 2003
    Posts
    20

    Problems adding items to listbox

    I am VERY new VBA programmer so I need some help. Below is my code. I cannot seem to get the items to add to my listbox. Below is what I found as code online as examples, but it doesn't seem to work. There are probably other problems as well, so if anyone has any suggestions, please, fire away!



    Please Login or Register  to view this content.

    It also may help to know that I am getting 'Runtime Error 424 Object Required' when I run the code.
    Last edited by mrapes; 06-08-2012 at 10:56 AM. Reason: more info needed

  2. #2
    Valued Forum Contributor
    Join Date
    02-09-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    1,055

    Re: Problems adding items to listbox

    Hi

    Upload your file where the listbox is present and also the data which you want to insert into the listbox with explanation....
    Click *, if my suggestion helps you. Have a good day!!

  3. #3
    Forum Contributor thameem127's Avatar
    Join Date
    04-06-2012
    Location
    Jeddah,Saudi Arabia
    MS-Off Ver
    Excel 2003,Excel 2007
    Posts
    321

    Re: Problems adding items to listbox

    Tr this

    Please Login or Register  to view this content.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Problems adding items to listbox

    Where's the code? Is it actually in the UserForm code window, it looks like you may have typed it in manually
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Problems adding items to listbox

    Here's a couple of examples how it should be done
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    06-07-2012
    Location
    Michigan
    MS-Off Ver
    Excel 2003
    Posts
    20

    Re: Problems adding items to listbox

    I have attached the file I am using. All I am trying to do is place the values (additem) into the listbox. I tried both ways that you guys mentioned above & neither one worked for me. Thank you all for your help.
    Attached Files Attached Files

  7. #7
    Valued Forum Contributor
    Join Date
    02-09-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    1,055

    Re: Problems adding items to listbox

    Hi

    The code to fill in the listbox named "errorlistbox":

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    06-07-2012
    Location
    Michigan
    MS-Off Ver
    Excel 2003
    Posts
    20

    Re: Problems adding items to listbox

    I appreciate the quick reply. I try that & it still isn't working. Is it possible that there is something else causing the problem?

  9. #9
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Problems adding items to listbox

    Did you bother reading my post or looking at the example that i took the time to attach?

    Your code is in the wrong place

  10. #10
    Registered User
    Join Date
    06-07-2012
    Location
    Michigan
    MS-Off Ver
    Excel 2003
    Posts
    20

    Re: Problems adding items to listbox

    I did read your post & look at your example. I failed to notice the code I was missing at the top. I apologize. Your code works when I run it, but when I copy it into mine, it won't work on my userform. I don't see what the problem is.

  11. #11
    Registered User
    Join Date
    06-07-2012
    Location
    Michigan
    MS-Off Ver
    Excel 2003
    Posts
    20

    Re: Problems adding items to listbox

    I apologize for not realize what I was doing sooner. But I got the code to work by placing my code in two separate windows. I don't know why this was necessary, but it worked!

  12. #12
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Problems adding items to listbox

    Any code that is a UserForm event code like the Initialize should be in the UserForm code window. You make sure that you are working with that buy double clicking on the UserForm in the VB Editor & selecting the event from the right hand drop down

  13. #13
    Registered User
    Join Date
    06-07-2012
    Location
    Michigan
    MS-Off Ver
    Excel 2003
    Posts
    20

    Re: Problems adding items to listbox

    That makes a lot of sense. Thank you again for all of your help. I really appreciate it.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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