View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Honnore via OfficeKB.com Honnore via OfficeKB.com is offline
external usenet poster
 
Posts: 5
Default Selected ListBox item to TextBox

Let me put it in another way...
I have a ListBox which I populate with the additem "method". The ListBox has
14 column.
I would like to extract the value of each column of the selected item into
TextBoxes that are in an other Useform...
The here below code you gave me works fine until the 9th column:

Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
UserForm2.TextBox1 = ListBox1.List(ListBox1.ListIndex, 9)
End Sub

When willing to retreive the value of the 10th column and above it doesn't
work anymore. In clear words, the here below code doesn't work

Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
UserForm2.TextBox1 = ListBox1.List(ListBox1.ListIndex, 10)
End Sub


Rick Rothstein wrote:
What do you mean by "a value that is above the 9th column"? And what is the
"i" variable for? The code I posted was meant to replace all of your code
(notice I posted the event header and the End Sub statements with my single
line of code)... it was not meant to be merged with the code you posted.
Because you are using the DblClick event, the selected row will be the row
that the user double clicks on... the ListIndex that I used as an argument
for the List property returns that row number directly (where the first row
is numbered 0)... no loop is necessary to find it. Again, the code you will
actually need will depend on the first question I asked you above (and on
what "above" means in it).

Hi Rick...
First of all, thanks for this fast reply.

[quoted text clipped - 20 lines]
Thank you in advance for your help
Honnore


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200904/1