View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_5_] Dave Peterson[_5_] is offline
external usenet poster
 
Posts: 1,758
Default Form Input--Submit

Something like this worked ok for me:

Option Explicit
Private Sub CommandButton1_Click()

Dim iCtr As Long
Dim oRow As Long
Dim wks As Worksheet

Set wks = Worksheets("sheet2")

oRow = 1
With Me.ListBox1
For iCtr = 0 To .ListCount - 1
If .Selected(iCtr) Then
wks.Cells(oRow, "A").Value = .List(iCtr)
oRow = oRow + 1
End If
Next iCtr
End With

Unload Me

End Sub

Private Sub UserForm_Initialize()
Dim iCtr As Long

With Me.ListBox1
.MultiSelect = fmMultiSelectMulti
For iCtr = 1 To 10
.AddItem "asdf" & iCtr
Next iCtr
End With

End Sub

You'll want to loop through all the items in that listbox (0 to .listcount -1)
to see if it's selected.


evangray123 wrote:

Thanks for the tip......

Maybe you can tell me why I am having trouble getting the data from my
multiple selection listbox in my form, to the spreadsheet. It doesnt
seem to be transferring any of the info, and I am having some trouble
figuring it out. If the user selects multiple items, it should transfer
to the spreadsheet with each selection listed and seperated by a comma.

Thanks

--
evangray123
------------------------------------------------------------------------
evangray123's Profile: http://www.excelforum.com/member.php...o&userid=17429
View this thread: http://www.excelforum.com/showthread...hreadid=378164


--

Dave Peterson