Hi Folks,
I am absolutley hopeless with listboxes and arrays. However i have spent the last 2 hours having a go trying to combat it, lol.
Using VBA online help and MrExcel i have managed to creat the code below which places items from a worksheet into a userform listbox.
The list box contain 3 columns and list items from the worksheet Colums A2 to A7, C2 to C7 and H2 to H7.
I have tried to take it forward a step but cannnot find any thing that i understand well enough to do it either here on the net.
Instead at stopping at A7 i want it to include every row that has something in it, the same for C and H.
I would be grateful if someone could explain or show me how to do it. I just cannot grasp arrays.
Heres my code so far:
Thanks
I am absolutley hopeless with listboxes and arrays. However i have spent the last 2 hours having a go trying to combat it, lol.
Using VBA online help and MrExcel i have managed to creat the code below which places items from a worksheet into a userform listbox.
The list box contain 3 columns and list items from the worksheet Colums A2 to A7, C2 to C7 and H2 to H7.
I have tried to take it forward a step but cannnot find any thing that i understand well enough to do it either here on the net.
Instead at stopping at A7 i want it to include every row that has something in it, the same for C and H.
I would be grateful if someone could explain or show me how to do it. I just cannot grasp arrays.
Heres my code so far:
Code:
Dim SCH2 As Worksheet
Dim i As Single
Set SCH2 = Sheets("Schedule 2")
'The 1st list box contains 3 data columns
ListBox1.ColumnCount = 4
'Load integer values into first column of MyArray
For i = 0 To 5
MyArray(i, 0) = i
Next i
'Load columns 2 and three of MyArray
MyArray(0, 1) = SCH2.Range("A2")
MyArray(1, 1) = SCH2.Range("A3")
MyArray(2, 1) = SCH2.Range("A4")
MyArray(3, 1) = SCH2.Range("A5")
MyArray(4, 1) = SCH2.Range("A6")
MyArray(5, 1) = SCH2.Range("A7")
MyArray(0, 2) = SCH2.Range("C2")
MyArray(1, 2) = SCH2.Range("C3")
MyArray(2, 2) = SCH2.Range("C4")
MyArray(3, 2) = SCH2.Range("C5")
MyArray(4, 2) = SCH2.Range("C6")
MyArray(5, 2) = SCH2.Range("C7")
MyArray(0, 3) = SCH2.Range("H2")
MyArray(1, 3) = SCH2.Range("H3")
MyArray(2, 3) = SCH2.Range("H4")
MyArray(3, 3) = SCH2.Range("H5")
MyArray(4, 3) = SCH2.Range("H6")
MyArray(5, 3) = SCH2.Range("H7")
'Load data into ListBox1
ListBox1.List() = MyArray