View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
jpendegraft[_3_] jpendegraft[_3_] is offline
external usenet poster
 
Posts: 1
Default Excel VBA-Looping though MultiSelect on ListBox

I am trying to loop a procedure to run for EACH item selected in
ComboBox.

Basically, I want to populate a spreadsheet based with the value in
textbox from a userform that also contains a ComboBox (this wil
isolate the column) and a listbox (this will isolate the multple row
that need to be populated).

Right now, it will properly populate the LAST item selected in th
listbox, rather than ALL items selected.

My current code is as follows:

Private Sub InsertClassDates()
For i = 1 To ListBox1.ListCount - 1
If ListBox1.Selected(i) = True Then _
r = ListBox1.ListIndex + 2
Select Case True
Case ComboBox1.ListIndex = 0: Cells(r, 6) = TextBox1.Value
Case ComboBox1.ListIndex = 1: Cells(r, 7) = TextBox1.Value
Case ComboBox1.ListIndex = 2: Cells(r, 8) = TextBox1.Value
Case ComboBox1.ListIndex = 3: Cells(r, 9) = TextBox1.Value
Case ComboBox1.ListIndex = 4: Cells(r, 10)
TextBox1.Value
End Select
Next i
Unload UserForm1
End Su

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