I am working on a excel reporting tool. The scenario is like this, when I click the button on my excel reporting tool I want to paste my "iferror(vlookup)" formula on the selected active workbook and that formula will do the lookup on another different workbook.
Here is my current code:
Workbooks("OR_" & fMonth & "selected active workbook.xlsx").Activate
f1 = "=COUNTIF(workbook where to lookup" & month & ".xlsx!$C:$C,J2)"
f2 = "=IFERROR(VLOOKUP(J2,workbook where to lookup" & month & ".xlsx!$C:$E,3,FALSE),"")"
ActiveSheet.Range("BK2").formula = f1
ActiveSheet.Range("BL2").formula = f2
But when I run this code I am getting this error:
run-time error '1004':
Application-defined or object-defined error.
Please help me get this done. Any response will be appreciated. Thanks in advance