VBA macro Insert formula and then copy down 1004 application defined or object defined error

colgert

New Member
Joined
May 28, 2017
Messages
10
My excel file consists of 2 worksheets, "result" and "merchant2"
Trying to insert this formula in cell C1 of sheet "result" and then copy down:

Code:
=IFERROR(VLOOKUP(A1;merchant2.csv!$A$1:$B$1000;2;FALSE);"")

The formula works normally if I insert it manually, but if I want to do it through VBA (including the copy down in the code) I get error 1004 application defined or object defined error

I tried double quoting the quotes but same thing

I can see the line where formula is highlighted in yellow

Code:
Sub FillDown()

    Sheets("result").Range("C1:C" & LastRow).Formula = "=IFERROR(VLOOKUP(A1;merchant2!$A$1:$B$1000;2;FALSE);"""")"

End Sub

I know there are other posts about this but formulas vary and didn't want to hijack them with my question
Thank you for your help in advance.
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
which excel language are you in
 
Upvote 0
and it is not merchant2.csv in the formula, just merchant2, but I can't edit my post.
Also I read about the possibility of problems because of locked/protected cells, but it is not my case.
 
Upvote 0
English usually uses , (comma) not (semi-colon) ;

post editing is controlled to 10 mins
 
Upvote 0
you will have a different default set, thats a common issues when codes don't run.

1004 normally indicates something is missing, like a sheet name is spelt wrong
 
Upvote 0
It has to be some syntax error when I put the formula in the vba code. That's what I really don't know.
The thing is, the formula works perfect (as it is now, with semi-colons and all) when inserted manually, and copied down manually, not giving any error about sheet names or anything.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,029
Messages
6,122,757
Members
449,094
Latest member
dsharae57

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top