View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Selected ListBox item to TextBox

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).

--
Rick (MVP - Excel)


"Honnore" <u51305@uwe wrote in message news:94e0ba9986331@uwe...
Hi Rick...
First of all, thanks for this fast reply.
I changed my code to the following and it wotks partially:
UserForm2.TextBox1.Value = UserForm1.ListBox1.List(i, 9)

I say partially because if I want to add in the TextBox a value that is
above
the 9th column of the selected item in the ListBox, it doesn't work
anymore.
Strange.

If you or someone else has an idea it would be more than welcome



Rick Rothstein wrote:
Try this DblClick event code instead of what you posted...

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

Hi there dear reader...
Usually I find all responses to my Excel issues in already existing

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