ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   User form with a listbox (https://www.excelbanter.com/excel-programming/274999-re-user-form-listbox.html)

John Green[_2_]

User form with a listbox
 
Kimberly,

Use the Selected property to test that an item has been selected:

Private Sub CommandButton1_Click()
Dim i As Integer

With ListBox1
For i = 0 To .ListCount - 1
If .Selected(i) Then
MsgBox .List(i)
End If
Next i
End With
End Sub


--

John Green - Excel MVP
Sydney
Australia


"KimberlyC" wrote in message ...
Hi
I have created a User from with a List box. The listbox is populated from a
range (V14:V25) on my worksheet.
The listbox is set to multi select the items.
I want to have the user select the items, and when they click the OK button
on the form... the items selected will copy or go to a range called
"headers" on a worksheet 2.
I'm not sure of the code to use to get those selected items to that range
when the user clicks the ok button.

Any suggestions would be greatly appreciated.

Thanks,
Kimberly





KimberlyC

User form with a listbox
 
Thank you!

How do I take those selected items and copy them to a different range on a
worksheet?


"John Green" wrote in message
...
Kimberly,

Use the Selected property to test that an item has been selected:

Private Sub CommandButton1_Click()
Dim i As Integer

With ListBox1
For i = 0 To .ListCount - 1
If .Selected(i) Then
MsgBox .List(i)
End If
Next i
End With
End Sub


--

John Green - Excel MVP
Sydney
Australia


"KimberlyC" wrote in message

...
Hi
I have created a User from with a List box. The listbox is populated

from a
range (V14:V25) on my worksheet.
The listbox is set to multi select the items.
I want to have the user select the items, and when they click the OK

button
on the form... the items selected will copy or go to a range called
"headers" on a worksheet 2.
I'm not sure of the code to use to get those selected items to that

range
when the user clicks the ok button.

Any suggestions would be greatly appreciated.

Thanks,
Kimberly







John Green[_2_]

User form with a listbox
 
To place the selected values in a column, starting in B1:

Private Sub CommandButton1_Click()
Dim i As Integer
Dim j As Integer

With ListBox1
For i = 0 To .ListCount - 1
If .Selected(i) Then
Range("B1").Offset(j, 0).Value = .List(i)
j = j + 1
End If
Next i
End With
End Sub


--

John Green - Excel MVP
Sydney
Australia


"KimberlyC" wrote in message ...
Thank you!

How do I take those selected items and copy them to a different range on a
worksheet?


"John Green" wrote in message
...
Kimberly,

Use the Selected property to test that an item has been selected:

Private Sub CommandButton1_Click()
Dim i As Integer

With ListBox1
For i = 0 To .ListCount - 1
If .Selected(i) Then
MsgBox .List(i)
End If
Next i
End With
End Sub


--

John Green - Excel MVP
Sydney
Australia


"KimberlyC" wrote in message

...
Hi
I have created a User from with a List box. The listbox is populated

from a
range (V14:V25) on my worksheet.
The listbox is set to multi select the items.
I want to have the user select the items, and when they click the OK

button
on the form... the items selected will copy or go to a range called
"headers" on a worksheet 2.
I'm not sure of the code to use to get those selected items to that

range
when the user clicks the ok button.

Any suggestions would be greatly appreciated.

Thanks,
Kimberly









Wango

User form with a listbox
 
How did you set your list or reange to "Multi Select". I am going nut
trying to just do that. If you can, please outline the steps for me

--
Message posted from http://www.ExcelForum.com


Tom Ogilvy

User form with a listbox
 
right click
Properties
Multiselect property - set to true.

--
Regards,
Tom Ogilvy

"Wango" wrote in message
...
How did you set your list or reange to "Multi Select". I am going nuts
trying to just do that. If you can, please outline the steps for me.


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 01:31 AM.

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