Matt Taylor
Matt Taylor

Reputation: 671

Unable to add formula to a cell

Formula is not adding to the spreadsheet.

I have look all around and tried many solutions that worked for others, but my immediate window is still saying False.

Range("C3:C" & Cells(Rows.Count, "A").End(xlUp).Row).Formula = 
"=IFERROR(INDEX(Print!$A$3:$A$999,MATCH(A3,Print!$B$3:$B$999,0)),"")"

Same problem on a simpler formula

Range("D3:D" & Cells(Rows.Count, "A").End(xlUp).Row).Formula = 
"=IF(A3 <> "",RIGHT(A3,4),"")"

Script runs but nothing happens in "C3" or "D3". Where am i going wrong? Ultimately I want the formulas to be in cells C and D if A cell has anything.

Note: Both of these work if i paste them directly into the cells.

Upvotes: 0

Views: 48

Answers (1)

Allan
Allan

Reputation: 82

If you want to ignore the function of double quotes and have it just as text, add another double quotes to it.

This should work:

Range("D3:D" & Cells(Rows.Count, "A").End(xlUp).Row).Formula = "=IF(A3 <> """",RIGHT(A3,4),"""")"

Range("C3:C" & Cells(Rows.Count, "A").End(xlUp).Row).Formula = "=IFERROR(INDEX(Print!$A$3:$A$999,MATCH(A3,Print!$B$3:$B$999,0)),"""")"

Upvotes: 1

Related Questions