+ Reply to Thread
Results 1 to 6 of 6

VBA / Macro for ListBox?

  1. #1
    Registered User
    Join Date
    06-05-2012
    Location
    Lebanon, NH
    MS-Off Ver
    Excel 2007
    Posts
    40

    VBA / Macro for ListBox?

    Currently I have figured out how to allow multiple items to be chosen in a list box; however, when I click the "add" button, it doesn't place the information into my spreadsheet. I am assuming it's due to the macro for the "add" button, but I cannot figure this out.

    Suggestions?

    I have uploaded the spreadsheet for review.
    Attached Files Attached Files

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: VBA / Macro for ListBox?

    you have to loop through the items and check which are selected so change the code to
    Please Login or Register  to view this content.
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  3. #3
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,431

    Re: VBA / Macro for ListBox?

    If you have a multi selet list you need to go through the Selected array and store the information before writing out.

    This will store the codes as a comma seperated list

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  4. #4
    Registered User
    Join Date
    06-05-2012
    Location
    Lebanon, NH
    MS-Off Ver
    Excel 2007
    Posts
    40

    Re: VBA / Macro for ListBox?

    Hello JP,

    Thank you for this. I tried to use this code but it gave me an error. It gave me a "Syntax Error" and the line "Private Sub cmdADD_Click" was highlighted.

    Any ideas on why this would happen?

  5. #5
    Registered User
    Join Date
    06-05-2012
    Location
    Lebanon, NH
    MS-Off Ver
    Excel 2007
    Posts
    40

    Re: VBA / Macro for ListBox?

    Andy,

    This will be useful, thank you.
    One question, where do I place this code? Does it matter?

    I'm quite new to VBA and I'm learning as I go.

  6. #6
    Registered User
    Join Date
    06-05-2012
    Location
    Lebanon, NH
    MS-Off Ver
    Excel 2007
    Posts
    40

    Re: VBA / Macro for ListBox?

    OOOHHH! Scratch that! It's working perfectly!!

    Thank you so much. I have been scratching my head for days on this!

+ 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