more than one column in a list box


Posted by Steven Scaife on August 23, 2001 5:58 AM

I have a problem in Excel 97, I have never really used it anyway.

I need to have a list box that has multiple columns eg

Package Price Order Code
----------------------------------------
AutoCAD £3000 xx556678x
Win98 £80 xxuhygtyx

etc.

When the user selects the package, i need it to populate the 3 cells next to each other.

Is this possible, I may be able to figure out the code for the cells but if you know how to format the list box please let me know

cheers

Posted by Robb on August 23, 2001 6:20 AM

Steven

Try this - you'll have to play around with the ranges etc:

It is code for a commandbutton, but you could use it wherever you want.

Private Sub CommandButton1_Click()

On Error Resume Next
ListBox1.ColumnCount = 4
rw = 0
For Each r In Worksheets("sheet1").UsedRange.Rows
n = r.Row
If Worksheets("sheet1").Cells(n, 2) < 5 Then
Myentry = Worksheets("sheet1").Cells(n, 1)
Myentry2 = Worksheets("sheet1").Cells(n, 2)
Myentry3 = Worksheets("sheet1").Cells(n, 3)
Myentry4 = Worksheets("sheet1").Cells(n, 4)
ListBox1.AddItem Myentry
ListBox1.List(rw, 1) = Myentry2
ListBox1.List(rw, 2) = Myentry3
ListBox1.List(rw, 3) = Myentry4
rw = rw + 1
Else
End If
Next r
End Sub


Any help?

Regards



Posted by steven scaife on August 23, 2001 6:40 AM

Cheers for the help much appreciated