View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
NateBuckley NateBuckley is offline
external usenet poster
 
Posts: 146
Default Getting list data into spreadseet

Sub ListBoxToCells()

Dim indexTo As Long
Dim i As Long
Dim j As Long
Dim var As Variant
'Get how many records exist within the listbox and store that into a
variable
indexTo = ListBox1.ListCount
'This will hold the List so we can go through it
var = ListBox1.List
j = 1
'The List starts at element 0 (in the array), so we'll start the i
counter there.
For i = 0 To indexTo - 1
'Print out to the Cells.
Sheet1.Cells(j, 1).Value = var(i, 0)
j = j + 1
Next i
End Sub

Hope this helps, if you wish for me to go into more detail then I shall, but
it's all fairly straight forward stuff.

"Anand" wrote:

I have a UserForm in which I have a List Box. The user can add items
to the list box. At the end I have to get all items from the list box
control and transfer them into a spreadsheet column.
Appreciate any help to achieve this.

Thanks,
Anand.