Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Binding data to a ListBox without using cells Max Excel Programming 3 August 10th 05 03:14 PM
Linking Cells to ListBox - How? William C. Smith Excel Programming 2 December 29th 03 10:53 PM
Putting Listbox data in cells Todd Huttenstine[_2_] Excel Programming 2 November 23rd 03 12:56 AM
listbox.value not equal to listbox.list(listbox.listindex,0) ARB Excel Programming 0 October 22nd 03 12:46 AM
Sorting ListBox results or transposing ListBox values to other cells for sorting Rob[_8_] Excel Programming 1 July 9th 03 04:35 AM


All times are GMT +1. The time now is 03:52 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright Š2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"