Hi,
I'm trying to insert in a range a VLOOKUP formula that will return data from another closed workbook but the line where the formula is inserted returns error 1004
Here is the code:
If I manually enter the formula and replace the dynamic cell address part it works.
Can someone please tell me what is the problem with this code?
I'm trying to insert in a range a VLOOKUP formula that will return data from another closed workbook but the line where the formula is inserted returns error 1004
Here is the code:
Code:
Sub insFormula()
Dim c As Range
Dim LastRow As Integer
With ActiveSheet
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For Each c In .Range("A2:A" & LastRow)
c.Offset(0, 4) = "=VLOOKUP(" & c.Address(0, 0) & ";'C:\Users\Dan\Desktop\[stoc.xlsx]stoc total'!B:I;8;0)"
Next c
End With
End Sub
If I manually enter the formula and replace the dynamic cell address part it works.
Can someone please tell me what is the problem with this code?