Error inputting formula using macro

csexcel

New member
Joined
Jun 22, 2015
Messages
2
Reaction score
0
Points
0
I have created a formula that works perfectly when manually entered into a cell, the formula is as follows:

=IFERROR(IF(ISNA(VLOOKUP('Worksheet2'!B:B,'Worksheet3'!A:A,1,FALSE)),IF(AND('Worksheet2'!C:C<>"",IF('Worksheet2'!C:C<=$J$4,'Worksheet2'!B:B,"")),IF('Worksheet2'!C:C>=$I$4,'Worksheet2'!B:B,""),""),""),"")

However, I want to assign a macro that will input this formula into a cell, for instance cell H2, I created this:

Range("H2").Formula = "=IFERROR(IF(ISNA(VLOOKUP('Worksheet2'!B:B,'Worksheet3'!A:A,1,FALSE)),IF(AND('Worksheet2'!C:C<>"",IF('Worksheet2'!C:C<=$J$4,'Worksheet2'!B:B,"")),IF('Worksheet2'!C:C>=$I$4,'Worksheet2'!B:B,""),""),""),"")"

However, when I attempt to run this macro, I get the error "Run-time error '1004': Application-defined or object-defined error"

What could be the issue?
 
godda love those double quotes..... try this

Range("H2").Formula = "=IFERROR(IF(ISNA(VLOOKUP('Worksheet2'!B:B,'Worksheet3'!A:A,1,FALSE)),IF(AND('Worksheet2'!C:C<>" & """""" & ",IF('Worksheet2'!C:C<=$J$4,'Worksheet2'!B:B," & """""" & ")),IF('Worksheet2'!C:C>=$I$4,'Worksheet2'!B:B," & """""" & ")," & """""" & ")," & """""" & ")," & """""" & ")"
 
Back
Top