I have a combobox in worksheet. After I execute the subroutine cmdUpdateDropDowns()
, there is a pop up error message saying "Object required" Run-time error '424'. This occurs in line 5 (cmbKeyMetrics.Clear
). I am not sure how to define combobox in worksheet. I have named range it cmbKeyMetrics
Public Sub cmdUpdateDropDowns()
strSQL = "Select Distinct [Key Metrics] From [data$] Order by [Key Metrics]"
closeRS
OpenDB
cmbKeyMetrics.Clear
rs.Open strSQL, cnn, adOpenKeyset, adLockOptimistic
If rs.RecordCount > 0 Then
Do While Not rs.EOF
cmbKeyMetrics.AddItem rs.Fields(0)
rs.MoveNext
Loop
Else
MsgBox "No key metrics available.", vbCritical + vbOKOnly
Exit Sub
End If