Hi,
Trying to loop through key-value pairs in a data dictionary and use those values in a sub I'm calling but keep getting the error Byref Type Mismatch. Can't figure out what the problem is.
Any ideas?
This is the sub I'm calling:
The sub works perfectly when implemented like this:
What I'm trying to do is create a data dictionary with all the key - item pairs and loop through that sub. Something like this:
The error is flagging this portion of the code:
Tried removing the "" on the dictionary keys as those are used as a ComboBox object in the sub but that didn't really work.
Trying to loop through key-value pairs in a data dictionary and use those values in a sub I'm calling but keep getting the error Byref Type Mismatch. Can't figure out what the problem is.
Any ideas?
This is the sub I'm calling:
VBA Code:
Sub DropDown(o As MSForms.ComboBox, r As String)
Dim I As Worksheet
Set I = Worksheets("Inputs")
o.List = I.Range(r).Value
End Sub
The sub works perfectly when implemented like this:
Code:
'DJOHS DROPDOWN'
Call DropDown(SDJOHSComboBox, "DJOHS")
Call DropDown(LDJOHSComboBox, "DJOHS")
What I'm trying to do is create a data dictionary with all the key - item pairs and loop through that sub. Something like this:
Code:
Dim iDict As New Scripting.dictionary
'Create a Dictionary Object
iDict.Add "SStageComboBox", "Stage"
iDict.Add "SYearComboBox", "Year"
iDict.Add "LYearComboBox", "Year"
iDict.Add "SPeriodComboBox", "Period"
iDict.Add "LPeriodComboBox", "Period"
'Loop Thru each key item pair
For Each I In iDict.Keys
Call DropDown(iDict.Keys(I), iDict.Items(I))
Next I
The error is flagging this portion of the code:
Code:
iDict.Keys(I)
Tried removing the "" on the dictionary keys as those are used as a ComboBox object in the sub but that didn't really work.