The formula would be something like =INDIRECT("A1") where the value in A1 equals a range name that lives on another worksheet.
OK. What I have done for the testing of the code below.
- Created a list on another worksheet.
- Create a defined name called cboList for the list on the other worksheet.
- Cell A1 contains cboList (Nothing else and no equals sign)
- Cell C1 contains list type data validation with formula =INDIRECT(A1)
- Created a ComboBox over top of cell C1.
A formula cannot be used for the ListFillRange so the formula needs to be evaluated so that the defined name can be used for the ListFillRange.
To see what the code does to extract the defined name for the combo box ListFillRange, uncomment the lines with stop and each time the code stops, hover the cursor over strList to see its value. I think this is easier than trying to explain in words what the code does. (To restart the code after the stop press F5 while in the VBA editor)
I understand that you have said that you cannot access OneDrive from work but I have uploaded a zipped copy of my test workbook to the following link so if you can access it from somewhere else then it might help.
If you cannot access it then if you provide me with an email address then I will email it to you. This forum automatically deletes email addresses so provide it as follows.
name AT DomainName DOT com
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Exit Sub 'Uncomment to suppress event during development
Dim strList As String
Application.EnableEvents = False
'Test if Target cell contains List type validation
'The If test line will error if not a validation cell and goto SkipProcess
On Error GoTo SkipProcess
If Target.Validation.Type = 3 Then
'Assign the List formula to a string variable
strList = Target.Validation.Formula1
'Stop
'Remove equal sign
strList = Replace(strList, "=", "")
'Stop
'Remove Indirect
strList = Replace(strList, "INDIRECT", "")
'Stop
'Evaluate what is in A1 to extract the defined name
strList = Evaluate(strList)
'Stop
'Assign the defined name to the combo listfillrange
Me.ComboBox1.ListFillRange = strList
Me.ComboBox1.Visible = True
Me.ComboBox1.DropDown
Application.EnableEvents = True
Exit Sub 'Skips making combo invisible
End If
SkipProcess:
Me.ComboBox1.Visible = False
Application.EnableEvents = True
End Sub
Private Sub ComboBox1_Change()
Application.EnableEvents = False
Me.ComboBox1.Visible = False
Application.EnableEvents = True
End Sub