need help with this piece of code for a list box


Posted by steven scaife on August 23, 2001 8:30 AM

That is the code i am using below. The problem that i am having with it is that when the line in the list box is selected it shows a name, a price and a code. when the button is pressed to place the line into the worksheet only the name is placed into the active cell. I also need the next two cells to be populated with the code and price. any ideas would be appreciated.

With UserForm1.ListBox1
selectedtext = .List(.ListIndex)
End With

' Display the selected value in a message box.
ActiveCell.Value = selectedtext

cheers

Posted by Damon Ostrander on August 23, 2001 3:06 PM

Hi Steven,

I assume that your listbox has 3 columns. If so, the following code should work:

With UserForm1.ListBox1
selectedtext = .List(.ListIndex,0)
pricetext = .List(.ListIndex,1)
codetext = .List(.ListIndex,2)
End With

' Display the selected value in a message box.
' Selection is the selected cell
Selection.Value = selectedtext
Selection.Offset(0,1).Value = pricetext
Selection.Offset(0,2).Value = codetext

Damon



Posted by steven scaife on August 24, 2001 1:43 AM

cheers, sorted it

Nice one it works sound now