PDA

View Full Version : Adding another Column to a list box?



KennyJ
09-24-2008, 05:35 AM
What do I need to add this this Sub to add the information from column "A" to the left of the Information being populated from Column "D" in my List box?

'Populate a multi-column combo and list box with values from spreadsheet
'when the form is loaded
Private Sub UserForm_activate()

Dim MyList(400, 3) 'as array type
Dim R As Integer
Set WS = Workbooks("COMPONENTS_33.xls").Sheets("Sheet1")

'You can configure the number of columns, their width and height below
'as well as change the text in the ControlTipText of the listbox
Application.ShowToolTips = True
With ListBox1
.ColumnCount = 1
.ColumnWidths = 75
.Width = 100
.Height = 110
.ControlTipText = ""
End With


With WS

'If you have more than 500 rows change this number and 1st line of this sub dim mylist
For R = 1 To 400
MyList(R, 0) = .Range("D" & R + 1)

Next R
End With

'populate the list box
ListBox1.List = MyList
TextBox1.SetFocus
End Sub

KennyJ
09-24-2008, 05:45 AM
Oops! I added this to the wrong forum This is supposed to be in the Excel forum.