Hi
In the attached workbook, I have a userform
the combobox ComboMainHead is being populated from the chart of accounts sheet. the problem is if the said sheet is not activated the combox is not populated.
What am I am doing wrong
Here is the code behind the userform
Private Sub UserForm_Initialize() Me.lblHeader.Caption = Sheet8.Range("A7").Value & vbNewLine & Sheet8.Range("A8").Value & vbNewLine & Sheet8.Range("A9").Value Dim myCollection As Collection, cell As Range On Error Resume Next Set myCollection = New Collection With Me.ComboMainHead .Clear For Each cell In Sheet4.Range("A3:A" & Cells(Rows.Count, 1).End(xlUp).Row) If Len(cell) <> 0 Then Err.Clear myCollection.Add cell.Value, cell.Value If Err.Number = 0 Then .AddItem cell.Value End If Next cell End With Me.ComboMainHead.ListIndex = 0 End Sub
Bookmarks