+ Reply to Thread
Results 1 to 7 of 7

List box with a divider between selected and unselected

  1. #1
    Registered User
    Join Date
    07-12-2007
    Posts
    24

    List box with a divider between selected and unselected

    I have searched thru the forums and haven't been able to find anything like this, maybe it can't be done.
    I will simplify my example, I have a spreadsheet that has a column of names A1-A20. I want the user to be able to open a userform and see two boxes. The one on the left will show the contents of A1-A20. There will be 2 arrows pointing left and right between the 2 boxes that will allow the user to move the A1-A20 titles between the left and right boxes. The right hand box will be the contents that the user wants to paste in cells B1-B20. Once the user press the OK button the contents of the right hand box will be copied to B1-B20. If the user goes back into the userform the right hand box will keep in memory the selection based on the contents of cell B1-B20.
    I have seen this done in various websites but I'm not sure if its possible in excel.
    Thanks
    Rob

  2. #2
    Forum Contributor SOS's Avatar
    Join Date
    01-26-2004
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel 2003
    Posts
    327
    Hi yzer19,

    I think this page has all the information you need. Moving Data Between ListBoxes
    Hope this helps

    Seamus

  3. #3
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,447
    I have created a class object to handle this type of thing.
    http://www.andypope.info/vba/listboxmover.htm
    Cheers
    Andy
    www.andypope.info

  4. #4
    Registered User
    Join Date
    07-12-2007
    Posts
    24
    THANKS very much for both replies that is exactly what I'm looking for. I have decided to try and modify Andy's to fit my project but I'm having a little difficulty. I've spent most of today trying to modify the vba with no success. I'm fairly new to the coding but really trying to learn. My problems are trying to adapt Andy's sample to the following:

    1. I want to remove the top section of the listbox as its cool but I don't need the ability to move items up or down. I can get rid of the actual boxes on the userform but when I try to delete the associated code I gets a lot of errors. Obviously I'm deleting the wrong things.
    2. I want to have an OK button at the bottom that copies the selection of the lower right hand box into a cell range on another sheet once the OK button is pressed.
    This might be dreaming but when the user opens the form again I would like the results from the last selection to appear on the right hand listbox so they don't have to start from scratch again. I'm going to have about 40 items in the left hand box and I don't want the user to have to start from scratch each time they open the form as most times they will only be adding or deleting 1 item.

    Again thanks so much for the help, this forum has taught me more than any course or book could ever.
    Rob

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,447
    Can you post what you have done?

    In order to keep setting between sessions you will need to store the information somewhere, such as a worksheet.
    The next time you load the userform you can check for any previous selections

  6. #6
    Registered User
    Join Date
    07-12-2007
    Posts
    24
    Andy - I have successfully taken out the top section of the list box and are left with only the 2 list boxes inside the form. A few things I can't solve
    -I understand how the "Remove Items on transfer" button works but I don't want to give the user the choice. I want this to always be checked so that the items are removed on the left side once selected on the right side. I have commented out the code but I'm left with the items not being removed, please help in setting this back up properly.
    -I'm not really sure were to start in getting the right hand box to copy into the output range (J2)
    -Also not sure on how to get the previous selections to retain for the next time the user opens the form. I understand what you mean by storing the settings between sessions in a workbook but I'm not sure where to start on this either.

    Maybe I'm in over my head on this one, but it seems so close to really making this thing work. I have attached my version of your example file, hope you don't mind me using your example as a template.

    Thanks again
    Rob
    Attached Files Attached Files

  7. #7
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,447
    See attached with modifications
    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)

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