I’m running Excel 2003. I have the following VBA code, corresponding to a simple UserForm comprising a ComboBox control and a Label control. It works through the save of the ComboBox but generates a Type mismatch error when saving the Label.
Private whatComboBox As ComboBox
Private whatLabel As Label
Private Sub UserForm_Initialize()
Call SaveComboBox(SomeComboBox)
Call SaveLabel(SomeLabel)
End Sub
Private Sub SaveComboBox(aComboBox As ComboBox)
Set whatComboBox = aComboBox
End Sub
Private Sub SaveLabel(aLabel As Label)
Set whatLabel = aLabel
End Sub
[And I do appreciate that VBA is limited in comparison to most other languages. But I wouldn’t have thought this was the kind of thing it would get wrong.]
Thanks all!
Try this
Regarding your query
You must qualify the Label object because Excel also has an object named Label
Alternative