Thread: listbox code
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default listbox code

Private Sub cmbSubmit_Click()
Dim i As Long, j as Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
j = 0
For i = 0 To Me.lstData.ListCount - 1
If Me.lstData.Selected(i) Then
ws.Range("B20").Offset(j, 0) _
.Value = Me.lstData.List(i,0)
ws.Range("C20").Offset(j,0) _
.Value = Me.LstData.List(i,1)
ws.Range("D20").Offset(j,0) _
.Value = Me.LstData.List(i,2)
j = j + 1
End If
Next i
End Sub

--
Regards,
Tom Ogilvy


"Jennifer" wrote:

Hello all,
I found this code in the archives and it gets me going in the right
direction, but i am going to need further direction.
I have a userform with a multi select listbox i would like the selections to
be pasted to a worksheet ("GwrStmts").
So far the code only paste one column of the info and not all 3 that are in
the list box and i need it to paste the info in area "b20:d50" (this is my
selected print area)

Thank you in advance. Gracias!

Private Sub cmbSubmit_Click()
Dim i As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
For i = 0 To Me.lstData.ListCount - 1
If Me.lstData.Selected(i) Then
ws.Range("Anchor").End(xlUp).Offset(1, 0) _
.Value = Me.lstData.List(i)
End If
Next i
End Sub

--
Though daily learning, I LOVE EXCEL!
Jennifer