Reputation: 39
Trying to populate a ComboBox on a UserForm when it initializes from a Named range. Have not had any luck. Any help is appreciated.
Private Sub MVPForm_Initialize()
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Broker ID Lookup")
'Add latest brokers
Me.BrokerName.List = ws.Range("MVP_Brokers").Value
End Sub
Upvotes: 0
Views: 180
Reputation: 71177
Never type event handler signatures by hand. If the method name isn't exactly as VBA expects it, then the callback won't be invoked. If the callback has parameters and your method doesn't have them all in the same order, very hard-to-debug problems can happen.
Instead, let the VBE create these method stubs for you, by picking an interface from the left-hand dropdown at the top of the code pane, then picking a method to implement in the right-hand dropdown:
The correct signature will be generated automatically every time:
Private Sub UserForm_Initialize()
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
End Sub
Watch the left dropdown: whenever you're inside what you expect to be an event handler and it says "(General)", you're actually looking at dead/unreachable code.
Upvotes: 1