I'm trying to use the following formula in a cell where Name is a defined cell. When I run 'MsgBox Name.Address' it gives me the correct cell, but when I run the formula I get
run-time error '1004'
Worksheets("E'ee Details").Range("N1").FormulaR1C1 = "=VLOOKUP(" & Name.Address & ",EmployeeBank!C[-13]:C[-10],4,FALSE)"
The code also correctly places in the value of the variable if I remove .address
Worksheets("E'ee Details").Range("N1").FormulaR1C1 = "=VLOOKUP(" & Name & ",EmployeeBank!C[-13]:C[-10],4,FALSE)"
This gives me =VLOOKUP(J Bob,EmployeeBank!A:D,4,FALSE) in the cell. This would work but I can't put quotation marks around the name as these are already in place in the vba code. I tried doing multiple quotation marks and also char(34) but couldn't get it to work.
Find(withOffset) is a much better alternative in VBA