+ Reply to Thread
Results 1 to 9 of 9

listbox items transfer

  1. #1
    Registered User
    Join Date
    07-01-2009
    Location
    Croatia
    MS-Off Ver
    Excel 2003
    Posts
    63

    listbox items transfer

    I have a userform with two listboxes and three command buttons.

    Listbox1 has Rowsource ("a1:a12)

    With commandbutton1 (Add) I am adding selected items from listbox1 to listbox2.
    With commandbutton2 (Delete) I am deleting items from listbox2.

    Third commandbutton is Ok.

    I would like with ok button transfer all items from listbox2 to worksheet - Columns (B:B).

    How can I do that?
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    Re: listbox items transfer

    You can extent the OK button with
    Please Login or Register  to view this content.
    Looking for great solutions but hate waiting?
    Seach this Forum through Google

    www.Google.com
    (e.g. +multiple +IF site:excelforum.com/excel-general/ )

    www.Google.com
    (e.g. +fill +combobox site:excelforum.com/excel-programming/ )

    Ave,
    Ricardo

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

    Re: listbox items transfer

    alternative

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

  4. #4
    Registered User
    Join Date
    07-01-2009
    Location
    Croatia
    MS-Off Ver
    Excel 2003
    Posts
    63

    Re: listbox items transfer

    It works, but if there are no items selected, then Run time error 1004 apears when I click ok button.

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

    Re: listbox items transfer

    then add a line to check the listcount property first.

    Better yet only enable the button when listbox contains items.

  6. #6
    Registered User
    Join Date
    07-01-2009
    Location
    Croatia
    MS-Off Ver
    Excel 2003
    Posts
    63

    Re: listbox items transfer

    I tried several codes but no one works. Errror always appears.

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

    Re: listbox items transfer

    It would have helped if you had posted what you had tried and details on the error.

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    07-01-2009
    Location
    Croatia
    MS-Off Ver
    Excel 2003
    Posts
    63

    Re: listbox items transfer

    And if ListBox2 is Multiselect and if I want to transfer only selected items (at once, not one by one) to worksheet (Columns B:B), how can I do that?

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

    Re: listbox items transfer

    You can not do it in one go. You can loop through the listbox and load the data into an array. You can then write the array to the worksheet with 1 line of code.

    Why the need to do it in one rather than item by item?

+ 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