ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Multiselect Listbox use (https://www.excelbanter.com/excel-discussion-misc-queries/88308-multiselect-listbox-use.html)

RKS

Multiselect Listbox use
 
Once I multiple select on the listbox created from Forms tool box - how do I
use it ... where do I have the results of multiple selection

Dave Peterson

Multiselect Listbox use
 
You'll need a macro to extract the values.

I'd put a button from that same Forms toolbar right next to the listbox. Then
the user can click that button when they want to extract the values.

Then assign this kind of code to that button:

Option Explicit
Sub testme()

Dim myLB As ListBox
Dim DestCell As Range
Dim iCtr As Long

With ActiveSheet
Set DestCell = .Range("B1")
Set myLB = .ListBoxes("List box 1")
End With

With myLB
'clear out previous entries?
DestCell.Resize(.ListCount, 1).ClearContents

For iCtr = 1 To .ListCount
If .Selected(iCtr) Then
DestCell.Value = .List(iCtr)
Set DestCell = DestCell.Offset(1, 0)
End If
Next iCtr
End With

End Sub



RKS wrote:

Once I multiple select on the listbox created from Forms tool box - how do I
use it ... where do I have the results of multiple selection


--

Dave Peterson


All times are GMT +1. The time now is 07:50 AM.

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