I'm trying to set an object variable to a listbox (not the selected item, the listbox itself). I've tried declaring the variable as a ListBox and as a Control, but neither works. For example, the following returns a type mismatch error:
I get the same error if I dim cListBox as a Control. Sheet1.lstProduct exists and comes up in autocomplete, so it isn't that the control isn't there. Does anyone know how to do this? Is it even possible?
The reason I'm trying to do this is that I have several similar list boxes that are used to set values in a SQL query and I'd like to have one Function for all of them instead of one for each, since the code is almost identical for each one.
Code:
Dim cListBox As ListBox
Set cListBox = Sheet1.lstProduct
I get the same error if I dim cListBox as a Control. Sheet1.lstProduct exists and comes up in autocomplete, so it isn't that the control isn't there. Does anyone know how to do this? Is it even possible?
The reason I'm trying to do this is that I have several similar list boxes that are used to set values in a SQL query and I'd like to have one Function for all of them instead of one for each, since the code is almost identical for each one.