I've got two workbooks, "Test" and "Screen_Reference_Data_Sheet". I am trying to create a dropdown list in "Test" by using a named range with data from the "Screen_Reference_Data_Sheet" workbook.
Below is the code I'm using, and it is throwing error Run Time Error 1004 on the ".Add Type:..." line.
I am able to accomplish this when only using data from one workbook, but it's when I am pulling data from another workbook that I am getting this error.
Sub GetScreenNames()
Path = Application.ActiveWorkbook.Path
RefFilePath = Path & "\Screen_Reference_Data_Sheet.xls"
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open(RefFilePath)
Dim rng1 As Range
Set rng1 = objWorkbook.Sheets("Keywords_Action_Screen").Range("B2:B4")
ThisWorkbook.Names.Add Name:="screenslistdata", RefersTo:=rng1
With ThisWorkbook.Sheets("Sheet1").Range("A1:A3").Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="=screenslistdata"
End With
objExcel.ActiveWorkbook.Close
objExcel.Application.Quit
End Sub
Any ideas on what I'm doing wrong here?
