PDA

View Full Version : [SOLVED:] complie error: Expected: end of statement



bradbeatDTD
10-20-2017, 01:53 PM
Hey guys

I'm simply trying to assign the following formula to a cell like this:

Range("P2") = "=IF(M2=100,"Complete",IF(J2<TODAY(),"Overdue",IF(J2-30<TODAY(),"Next Period","Future")))"

but I'm getting compile error: Expected: end of statement

Any help much appreciated

austenr
10-20-2017, 02:14 PM
try this in P2 and copy down or wherever you need it to be.


=IF(M2=100,"Complete",IF(J2<TODAY(),"Overdue",IF(J2-30<TODAY(),"Next Period","Future")))

mancubus
10-20-2017, 02:16 PM
Range("P2").Formula = "=IF(M2=100,""Complete"",IF(J2<TODAY(),""Overdue"",IF(J2-30<TODAY(),""Next Period"",""Future"")))"

double the quotes for strings in formulas.

write this worksheet formula in a cell
turn macro recorder on
select the cell
press F2 key then Enter
turn macro recorder off

open VBE window (Alt+F11) to see what macro recorder produced.

bradbeatDTD
10-21-2017, 10:36 AM
Thanks mancubus, that did it.