Within a User Form, I have the following VBA code written to populate a listbox of items (Column C) out on loan based on a combo box value (more specifically the person's name - Column B) from a loans spreadsheet. However, it does not run correctly - It executed correctly the first time I ran it, and then it did not. I have figured out that it only works when I Run the code (through VBA window) with the "Loans" sheet/tab on screen. How can I ensure this code works correctly when I am on the main user sheet/tab?
Any help would be appreciated!
Me.ListItem.Clear
With Worksheets("Loans").Range("B1:A" & (Cells(65536, 1).End(xlUp).Row))
Set c = .Find(cboName.Value, LookIn:=xlValues, Lookat:=xlWhole)
If Not c Is Nothing Then
firstAddress = c.Address
Do
Set c = .FindNext(c)
ListItem.AddItem .Cells(c.Row, 3).Value
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With
End Sub