Sheesh!! All I wanna do is….
In a project long long ago I needed to pull the selected value from a drop down on a User form and found the following code to work:
AInt = DialogSheets(“New Assignment”).DropDowns(1).Text
which loads the variable AInt with whatever was selected in the Drop Down on the user form. Now I’m trying to do the same thing but I keep getting the good old ‘out of range’ error when referencing the dialog sheet and drop down in code:
Sub ReturnSelection()
RegionalSelection = DialogSheets(“MainForm”).DropDowns(4).Text
MsgBox “You Chose ” & RegionalSelection
End Sub
I tried any number of numbers for the danged DropDown on the user form, and it is listed as Drop Down 4 in the Name box and also in the tab field box, so you’d think it’s actually what it claims to be…VBA can’t find it.
One small difference in the two, this particular drop-down box references a named range that is generated in code as I need to allow for additions/deletions of the options displayed.
I need to load a public variable with the text picked in the drop-down in order to set a lot of SQL strings with whatever choice is made in the dialog, so it is *crucial* that I get the data from the DropDown. I know some people will advise a goofy Select Case.. logic for the cell link and & don’t want to do that as I’ll have to edit it if and when the values change. It seems dirt easy to just grab the selected value but Mr VBA is not coorperating in one project and is happy in another, so what gives??
TIA