sdrloveshim
sdrloveshim

Reputation: 41

Error 1004 when inserting formula into cell using macro

I'm trying to use a macro to insert an equation into a cell. The equation works fine if I copy it in myself but I need to copy it to 6000 cells in each or four worksheets. This question seems pretty common, but the usual answer of replace ";" with "," doesn't apply. The first line catches error 1004.

Range("J1").FormulaLocal = "=IF(ISERROR(F1),"",IF(ISTEXT(F1),"",F1))"
Range("J1:J6000").FillDown 

I also tried using .formulaLocal but that doesn't seem to help.

Upvotes: 0

Views: 1080

Answers (1)

Scott Craner
Scott Craner

Reputation: 152505

You need to use double quotes to leave one quote:

Range("J1").FormulaLocal = "=IF(ISERROR(F1),"""",IF(ISTEXT(F1),"""",F1))"

Upvotes: 2

Related Questions