Formula not working in VBA, but works in cell
I am doing a conditional statement and I have automated my spreadsheet using VBA. Everything works fine until it comes to this one formula. I am guessing it has to do with the text strings. I have tried using & Chr(34) & before and after and it's not working either.
Here's the formula:
=IF(E2="RIA Review",IF(G2<=4,"Green",IF(G2=5,"Yellow","Red")), IF(E2="Delivery",IF(I2<=-7,"Green",IF(I2=-1,"Yellow","Red")),IF(E2="Launch/Close",IF(I2>=121,"Red",IF(I2>=111,"Yellow",IF(I2> =100,"Green","N/A"))),IF(OR(E2="Intent",E2="AE Review",E2="Initial Review",E2="AE Disposition"),IF(G2<=8,"Green",IF(OR(G2=9,G2=10)," Yellow",IF(G2>=11,"Red")))))))
Here's the code in VBA (it changes the cell references, which I still have a hard time knowing if it's talking about the right cell)
Range("H2").Select
ActiveCell.FormulaR1C1 = _
"=IF(RC[-3]=""RIA Review"",IF(RC[-1]<=4,""Green"",IF(RC[-1]=5,""Yellow"",""Red"")),IF(RC[-3]=""Delivery"",IF(RC[1]<=-7,""Green"",IF(RC[1]=-1,""Yellow"",""Red"")),IF(RC[-3]=""Launch/Close"",IF(RC[1]>=121,""Red"",IF(RC[1]>=111,""Yellow"",IF(RC[1]>=100,""Green"",""N/A""))),IF(OR(RC[-3]=""Intent"",RC[-3]=""AE Review"",RC[-3]=""Initial Review"",RC[-3]=""AE Disposition"")," & _
"]<=8,""Green"",IF(OR(RC[-1]=9,RC[-1]=10),""Yellow"",IF(RC[-1]>=11,""Red"")))))))"
Any help would be great!
|