+ Reply to Thread
Results 1 to 7 of 7

Controls toolbox -Listbox query

  1. #1
    Registered User
    Join Date
    01-21-2007
    Posts
    12

    Controls toolbox -Listbox query

    Hi All,
    I need some guidance related to control toolbox object Listbox.

    I have created a Excel spread sheet with multiple list box. The users can select multiple selections from these listboxes. I have created a function for listbox1 where in it stores all selected items in a string. I need to do the same for the other listboxes as well but i am not able to create a generic function to fulfill the purpose.

    Following is the code used.
    Please Login or Register  to view this content.
    I did try creating another function to pass the listbox object but it results in a type mismatch error.

    Please Login or Register  to view this content.
    Could someone provide any suggestions?
    Thanks

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    I think these functions will do what you want.
    dataFromListBox(1) will return the string you want from ListBox1, datafromListBox(2) from ListBox2, etc.

    LBox(3) will return the object ListBox3. You may have to ajust the sheet name in LBox.
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    01-21-2007
    Posts
    12
    Thanks for the reply. I was thinking more along the lines of passing the listbox to the function itemselect and then referencing the selected items in the function. Is that possible?

  4. #4
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-21-2007
    Posts
    12
    Thanks heaps...the keyword 'Object' has done the trick.

    Thank you very much.

  6. #6
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    You're welcome.

  7. #7
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    In responce to the PM: I found no problem with passing the object argument. (I'm restricted to UserForm controls) I used both Object and msForms.ListBox object types with success.

    I did find a problem. The code above uses the .TopIndex property. That won't work (for me.) I didn't do sufficiant testing before posting that. The code should use the .ListCount property instead.
    Please Login or Register  to view this content.
    Last edited by mikerickson; 06-20-2007 at 09:40 PM.

+ 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