I am trying to make a dynamic Macro that takes the path in cells that users enter and paste them into other cells but its not working
Here are my variables
Dim FRLU As String
Dim LU As String
dir = Range("B1").Value
FRLU = Range("B2").Value
LU = Range("B3").Value
Table:
Enter Working Directory into B1: | C:\Users\User1\Documents\Test1 | |||
---|---|---|---|---|
Enter first Workbook into B2: | workbook1.xlsx | |||
Enter second Workbook into B3: | workbook2.xlsx |
This is the script I have that enters the XLookup into the new column:
lngLastRow = Cells(Rows.Count, "H").End(xlUp).Row
Range("N4").Formula = "=XLOOKUP(G4,'dir[FRLU]ColumnG'!$G$2:$G$1000,'dir[FRLU]ColumnE'!$E$2:$E$1000)
Range("N4").Copy Range("N5:N" & lngLastRow)
This gets entered into the cell and is copied all the way through the new column and throws me #N/A:
=XLOOKUP(G4,'dir[FRLU]ColumnG'!$G$2:$G$1000,'dir[FRLU]ColumnE'!$E$2:$E$1000)
This is what I want it to say:
=XLOOKUP(G4,'C:\Users\User1\Documents\Test1[workbook1.xlsx]ColumnG'!$G$2:$G$1000,'C:\Users\User1\Documents\Test1[workbook1.xlsx]ColumnE'!$E$2:$E$1000)