You can extent the OK button with![]()
Private Sub OKButton_Click() Dim LBCounter As Long For LBCounter = 0 To ListBox2.ListCount - 1 Worksheets("List1").Cells(LBCounter + 1, "B") = ListBox2.List(LBCounter) Next Unload Me End Sub
You can extent the OK button with![]()
Private Sub OKButton_Click() Dim LBCounter As Long For LBCounter = 0 To ListBox2.ListCount - 1 Worksheets("List1").Cells(LBCounter + 1, "B") = ListBox2.List(LBCounter) Next Unload Me End Sub
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
alternative
![]()
Private Sub OKButton_Click() Worksheets("List1").Cells(1, 2).Resize(ListBox2.ListCount, 1) = ListBox2.List Unload Me End Sub
It works, but if there are no items selected, then Run time error 1004 apears when I click ok button.
then add a line to check the listcount property first.
Better yet only enable the button when listbox contains items.
I tried several codes but no one works. Errror always appears.
It would have helped if you had posted what you had tried and details on the error.
![]()
Private Sub OKButton_Click() if listbox2.listcount>0 then Worksheets("List1").Cells(1, 2).Resize(ListBox2.ListCount, 1) = ListBox2.List endif Unload Me End Sub
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?
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks