+ Reply to Thread
Results 1 to 10 of 10

Move selected columns data from UserForms listbox to different ranges in Worksheet

  1. #1
    Registered User
    Join Date
    02-18-2006
    Location
    WV
    MS-Off Ver
    2003,2007,2010
    Posts
    69

    Move selected columns data from UserForms listbox to different ranges in Worksheet

    Hello, I have a listbox with 4 rows of data (ColumnCount 4) and I want to be able to select one row in the listbox and click a button called (btnCopyToWorkorder) and have the columns form the listbox go into a Workbook sheet called (WorkOrder).

    listbox Colmuns 1, 2, 3, 4 value moved to selected cells in WorkSheet (WorkOrder).

    1 to C10:C46
    2 to E3
    4 to C6
    5 to F6


    How can I do this?

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

    Re: Move selected columns data from UserForms listbox to different ranges in Worksheet

    Hi.

    You mean to say that:
    1. the listbox has "1,2,4,5" as one column
    2. these values have to be copied into the cells specified above.

    Please confirm..
    Click *, if my suggestion helps you. Have a good day!!

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

    Re: Move selected columns data from UserForms listbox to different ranges in Worksheet

    Hi.

    Check this code. Insert the controls first and then copy these code into the specified events:

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    02-18-2006
    Location
    WV
    MS-Off Ver
    2003,2007,2010
    Posts
    69

    Re: Move selected columns data from UserForms listbox to different ranges in Worksheet

    No it a typo, I appoligize…
    There are 4 columns in my UserForm’s listbox, those numbers are just telling you that:

    1. Listbox column 1’s value would be moved to Range("C10:C46")in WorkSheet (WorkOrder)
    2. Listbox column 2’s value would be moved to Range("E3")in WorkSheet (WorkOrder)
    3. Listbox column 3’s value would be moved to Range("C6")in WorkSheet (WorkOrder)
    4. Listbox column 4’s value would be moved to Range(F6")in WorkSheet (WorkOrder)

    Question, is the columns just identified by a column number or how are they identified? And is there a way to just let the user select one row. The listbox is a multi select listbox but for this I need to just allow the user to select only one row.

    Thanks!
    Last edited by oxicottin; 01-24-2013 at 02:23 AM.

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

    Re: Move selected columns data from UserForms listbox to different ranges in Worksheet

    To refer to the selected value in the listbox we use this code:

    Please Login or Register  to view this content.
    This code will identify the selected value and the remaining part will paste that value to the specified range.

    Insert the below code in userform_activate event:

    Please Login or Register  to view this content.
    and the below code into commandbutton_click event:

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    02-18-2006
    Location
    WV
    MS-Off Ver
    2003,2007,2010
    Posts
    69

    Re: Move selected columns data from UserForms listbox to different ranges in Worksheet

    I cant get it to work... I created a striped down excel file with the user form and WorkOrder sheet and Sheet1 where the data comes from. Can you take a look?

    Thanks!


    New attachment 2 posts down
    Last edited by oxicottin; 01-25-2013 at 04:05 AM.

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

    Re: Move selected columns data from UserForms listbox to different ranges in Worksheet

    Check this out now:

    Book1.xlsm

  8. #8
    Registered User
    Join Date
    02-18-2006
    Location
    WV
    MS-Off Ver
    2003,2007,2010
    Posts
    69

    Re: Move selected columns data from UserForms listbox to different ranges in Worksheet

    jraj1106, the book1 you posted is still doing the same thing. I changed the listboxes rowsource in VBA because its always grabbing from that list. As of now its putting the row I selected Column 1 value in the worksheet (WorkOrder) cell F6. So it looks like its not even grabbing whats in the other columns in the row of the listbox.

    Here is a better example of the workbook.

    Thanks,
    Chad
    Attached Files Attached Files

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

    Re: Move selected columns data from UserForms listbox to different ranges in Worksheet

    Sorry for the delay. Now you can check this:

    TEST Move Listbox Data To Form.xlsm

  10. #10
    Registered User
    Join Date
    02-18-2006
    Location
    WV
    MS-Off Ver
    2003,2007,2010
    Posts
    69

    Re: Move selected columns data from UserForms listbox to different ranges in Worksheet

    Quote Originally Posted by jraj1106 View Post
    Sorry for the delay. Now you can check this:

    Attachment 209440
    Nobody in their right mind can complain for the help we receive and it is highly appreciated! The example works

    I think I see what you did, when the userform opens it counts the columns 1,2,3,4 .... Thanks again your help is very much appreciated!

+ 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