G
Gromit
In his blog, Dick Kusleika gives this code for populating a listbox. It
assumes the listbox has been set to to have a column count of 3, and
that there is data in columns A, B and C of Sheet 1. I've checked the
code and it works fine. However, I've tried using the same code to
populate a combobox, but it doesn't seem to work. Anyone any idea why?
Thanks, G
Private Sub UserForm_Initialize()
Dim cell As Range
Dim Rng As Range
With ThisWorkbook.Sheets(”Sheet1″)
Set Rng = .Range(”A2″, .Range(”A2″).End(xlDown))
End With
For Each cell In Rng.Cells
With Me.ListBox1
..AddItem cell.Value
..List(.ListCount - 1, 1) = cell.Offset(0, 1).Value
..List(.ListCount - 1, 2) = cell.Offset(0, 2).Value
End With
Next cell
End Sub
assumes the listbox has been set to to have a column count of 3, and
that there is data in columns A, B and C of Sheet 1. I've checked the
code and it works fine. However, I've tried using the same code to
populate a combobox, but it doesn't seem to work. Anyone any idea why?
Thanks, G
Private Sub UserForm_Initialize()
Dim cell As Range
Dim Rng As Range
With ThisWorkbook.Sheets(”Sheet1″)
Set Rng = .Range(”A2″, .Range(”A2″).End(xlDown))
End With
For Each cell In Rng.Cells
With Me.ListBox1
..AddItem cell.Value
..List(.ListCount - 1, 1) = cell.Offset(0, 1).Value
..List(.ListCount - 1, 2) = cell.Offset(0, 2).Value
End With
Next cell
End Sub