austin350s10
Active Member
- Joined
- Jul 30, 2010
- Messages
- 321
I am working with a userform and trying to load a combobox with values upon initialization. Below is the code i am trying to use which is just supposed to reference a sheet containing the values I want to use. The below code keeps giving me the error: "Run-time error '1004' Application-defined or object-defined error" Any ideas what I'm doing wrong here?
Code:
Private Sub UserForm_Initialize()
Dim ws As Worksheet
Set ws = Sheets("StaffList")
With Sheets("StaffList")
lastrow = ws.Cells(Rows.Count, 2).End(xlUp).Row
End With
i = 0
With Me.boxNames
.Clear
Do
.AddItem
.List(i, 0) = ws.Cells(i, 1).Value
.List(i, 1) = ws.Cells(i, 2).Value
i = i + 1
Loop Until i = lastrow
End With
End Sub