Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
data from listbox to cells
I've a 6-column listbox and I set the RowSource property to a named range. I
tried to copy selected row from listbox to worksheet but it does not work ( sometimes does, sometimes does not :( I dont understand why ) What is wrong? For index = 1 To 6 Worksheets("sht1").Cells(7 + index, 9) = ListBox1.list(ListBox1.ListIndex, index - 1) Next index -- icq 25372592 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
data from listbox to cells
Only problem I would see is if ListIndex = -1 (nothing selected)
-- Regards, Tom Ogilvy "Buddy Lee" wrote in message ... I've a 6-column listbox and I set the RowSource property to a named range. I tried to copy selected row from listbox to worksheet but it does not work ( sometimes does, sometimes does not :( I dont understand why ) What is wrong? For index = 1 To 6 Worksheets("sht1").Cells(7 + index, 9) = ListBox1.list(ListBox1.ListIndex, index - 1) Next index -- icq 25372592 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
data from listbox to cells
I used this:
Private Sub CommandButton2_Click() Dim index As Long For index = 1 To 6 Worksheets("sht1").Cells(7 + index, 9) = _ ListBox2.list(ListBox2.ListIndex, index - 1) Next index End Sub Make sure the listbox has Columncount = 6 Make sure you fully qualify your rowsource. Example mine was Sheet2!A2:F29 It worked fine for me (as expected) (my lisbox was names Listbox2 because I had another listbox on the form - but as long as you have the correct name, shouldn't be a problem). I also tried it in the click event of the listbox2 - worked as well Private Sub ListBox2_Click() Dim index As Long If ListBox2.ListIndex < -1 Then For index = 1 To 6 Worksheets("sht1").Cells(7 + index, 9) = _ ListBox2.list(ListBox2.ListIndex, index - 1) Next index End If End Sub -- Regards, Tom Ogilvy "Buddy Lee" wrote in message ... but that is impossible, I set ListBox1.ListIndex = 0 when form is activated is there another way to do this ? ( fill 6-column listbox with data than copy selected row to cells ) maybe the problem is something else, I dont know :( -- icq 25372592 "Tom Ogilvy" píše v diskusním příspěvku ... Only problem I would see is if ListIndex = -1 (nothing selected) -- Regards, Tom Ogilvy "Buddy Lee" wrote in message ... I've a 6-column listbox and I set the RowSource property to a named range. I tried to copy selected row from listbox to worksheet but it does not work ( sometimes does, sometimes does not :( I dont understand why ) What is wrong? For index = 1 To 6 Worksheets("sht1").Cells(7 + index, 9) = ListBox1.list(ListBox1.ListIndex, index - 1) Next index -- icq 25372592 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Binding data to a ListBox without using cells | Excel Programming | |||
Linking Cells to ListBox - How? | Excel Programming | |||
Putting Listbox data in cells | Excel Programming | |||
listbox.value not equal to listbox.list(listbox.listindex,0) | Excel Programming | |||
Sorting ListBox results or transposing ListBox values to other cells for sorting | Excel Programming |