Hey! I have this code that is clear won't work the way I want it to without relative references (R1C1). The original is this:
which works fine, but when I tried changing it to R1C1 (based on my limited knowlege), I'm getting a message to debug when I run it. Here's what I changed it to:
What do I need to change in order for this to work without asking to debug?? Thanks!
Code:
Cells(C.Row, "F").Formula = "=IF(E18=""Cost Per Stop"",ROUND(SUMIF(P:P,""sum1"",F:F)/SUMIF(S:S,""stop"",F:F),2),IF(E18=""Cost Per Directory"",ROUND(SUMIF(P:P,""sum1"",F:F)/SUMIF(S:S,""Book"",F:F),2),IF(E18=""Margin Percent (directs)"",ROUND(F16/SUMIF(P:P,""sum1"",F:F),2),IF(E18=""Margin Percent (Sales)"",-ROUND(F17/F14,2),IF(E18=""Gross Margin"",-((SUMIF(P:P,""sum1"",F:F))+G15),IF(E18=""total directs"",SUMIF(P:P,""Sum""&N17,F:F),SUMIF(R:R,""Total""&Q16,F:F)))))))"
which works fine, but when I tried changing it to R1C1 (based on my limited knowlege), I'm getting a message to debug when I run it. Here's what I changed it to:
Code:
Cells(C.Row, "F").Formula = "=IF(RC[-1]=""Cost Per Stop"",ROUND(SUMIF(C[10],""sum1"",C)/SUMIF(C[13],""Book"",C),2),IF(RC[-1]=""cost Per Directory"",ROUND(SUMIF(C[10],""Sum1"",C)/SUMIF(C[13],""book"",C),2),IF(RC[-1]=""Margin Percent (directs)"",ROUND(R[-2]C/SUMIF(C[10],""sum1"",C),2),IF(RC[-1]=""Margin Percent (sales)"",-ROUND(R[-1]C/R[-4]C,2),IF(RC[-1]=""gross margin"",-((SUMIF(C[10],""sum1"",C))+R[-3]C[1]),IF(RC[-1]=""total directs"",SUMIF(C[10],""sum""&R[-1]C[8],C),=IF(RC[-1]=""total directs"",SUMIF(C[10],""sum""&R[-1]C[8],C),SUMIF(C[12],""total""&R[-2]C[-2],C))))))))"
What do I need to change in order for this to work without asking to debug?? Thanks!