VBA - Listbox1 and Listbox2 data move to sheet1

  • Hi

    I have data in sheet1, column A which is assigned to Listbox1. When i select listbox1, data of sheet1, column B need to be populated in lsitbox2.

    Once i select the required data in listbox1, both the data of listbox need to be moved to sheet2, column A and Column B.

    Can anyone share the code please ? Attaching the file with few codes already in it.

  • Try this.


  • Hi

    I have data in column A and column B in sheet1. I'm preparing a listbox1 and listbox2.

    I'm pulling listbox1 from column A . When I click on list1, it should automatically pull the listbox2 also. Once i select all the required fields in Listbox1, they need to stored in sheet2, column A.

    Both the data in sheet1, column A and Column B are different.

    I hope I'm clear in my query

  • Hi

    I have data in column A and column B in sheet1. I'm preparing a listbox1 and listbox2.

    I'm pulling listbox1 from column A . When I click on list1, it should automatically pull the listbox2 also. Once i select all the required fields in Listbox1, they need to stored in sheet2, column A.

    Both the data in sheet1, column A and Column B are different.

    I hope I'm clear in my query

  • Both have different data but they both are on the same row.



    You can have both column A & B in the same listbox, in your properties, change to column count=2 and change the range to include A2:B4



    Here is the code, it just needs to be in the Command Button


  • Sir

    It is working fine, thank you.

    Can you please help me in understanding the code -


    Code
    1. .Cells(.Rows.Count, 1).End(xlUp).Offset(1) = ListBox1.List(x, 0)
    2. .Cells(.Rows.Count, 2).End(xlUp).Offset(1) = ListBox1.List(x, 1)


    Is there any other way to code this