Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Getting list data into spreadseet
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. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Getting list data into spreadseet
Sub ListBoxToCells()
Dim indexTo As Long Dim i As Long Dim j As Long Dim var As Variant indexTo = ListBox1.ListCount var = ListBox1.List j = 1 For i = 0 To indexTo - 1 Sheet1.Cells(j, 1).Value = var(i, 0) j = j + 1 Next i End Sub Heres the code without the comments as they don't stay on the right lines when I copy and paste it into here, so I wouldn't want it not to work because something that should be commented, isn't. "NateBuckley" wrote: 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. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
data validation list: how do i 'force' a user to enter data from the list? | Excel Discussion (Misc queries) | |||
data validation list: how do i 'force' a user to enter data from the list? | Excel Discussion (Misc queries) | |||
How to view a list of data based on another list of data | Excel Discussion (Misc queries) | |||
converting vertical data list to horizontal data list | Excel Worksheet Functions | |||
Last row in spreadseet | Excel Programming |