ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   select mulitiple columns and items from a listbox (https://www.excelbanter.com/excel-programming/308054-select-mulitiple-columns-items-listbox.html)

TK

select mulitiple columns and items from a listbox
 
Hi:

The code below works for returning selected items
in a multiple select ListBox.

What Im trying to do (without much success) is modify the
code to select multiple items and multiple columns.

Any help or examples will be greatly appreciated.

Private Sub CommandButton1_Click()

For x = 0 To ListBox1.ListCount - 1

If ListBox1.Selected(x) = True Then
ActiveCell.Value = UserForm2.ListBox1.List(x)

End If
Next x

End Sub


Thanks TK



Tom Ogilvy

select mulitiple columns and items from a listbox
 
You can't select individual columns

Private Sub CommandButton1_Click()
Dim x as Long

For x = 0 To ListBox1.ListCount - 1
if x mod 2 = 0 then
ListBox1.Selected(x) = True
end if
Next x

End Sub

selects every other row. The multiselect property should be set to true.

--
Regards,
Tom Ogilvy



"TK" wrote in message
...
Hi:

The code below works for returning selected items
in a multiple select ListBox.

What I'm trying to do (without much success) is modify the
code to select multiple items and multiple columns.

Any help or examples will be greatly appreciated.

Private Sub CommandButton1_Click()

For x = 0 To ListBox1.ListCount - 1

If ListBox1.Selected(x) = True Then
ActiveCell.Value = UserForm2.ListBox1.List(x)

End If
Next x

End Sub


Thanks TK






All times are GMT +1. The time now is 11:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com