Hello everyone:
I am having an issue with my form initializing. The form name is frmAddRepresentative and has a combo box called cboRepName. The code below should run when the form initializes. But I am getting a run time error -2147467259 (80004005). Unespecified error. Not much help from that.
Also, I change UserForm_Initialize to frmAddRepresentative_Initialize, the form opens but I get a subscript out of range on the Me.cboRepName references.
I can't figure out what I am doing wrong.
I am having an issue with my form initializing. The form name is frmAddRepresentative and has a combo box called cboRepName. The code below should run when the form initializes. But I am getting a run time error -2147467259 (80004005). Unespecified error. Not much help from that.
Also, I change UserForm_Initialize to frmAddRepresentative_Initialize, the form opens but I get a subscript out of range on the Me.cboRepName references.
I can't figure out what I am doing wrong.
Code:
Option Explicit
Private Sub UserForm_Initialize()
Dim ws As Worksheet
Set ws = Worksheets("Rep Information")
UpdateComboLists
Me.cboRepName.SetFocus
End Sub
Private Sub UpdateComboLists()
Dim cName As Range
Dim ws As Worksheet
Set ws = Worksheets("Rep Information")
Me.cboRepName.Clear
For Each cName In ws.Range("repName")
With Me.cboRepName
.AddItem cName.Value
.List(.ListCount - 1, 1) = cName.Offset(0, 1).Value
End With
Next cName
End Sub