Hi
I've got a script that adds a formula to a cell and drags it down.
However, I'm stumped by the fact that one formula works, but the other doesn't!
So this Sub works (where the last line adds and drags the formula : "=IFERROR((AY16/K16)-AF16,"""")"
But the formula at the end of the second Sub isn't being accepted by the VB editor?
I tried to replace the single quotes with double quotes, but that didn't work? Is there any obvious reason why the VB editor wouldn't accept it?
But this one doesn't?
I've got a script that adds a formula to a cell and drags it down.
However, I'm stumped by the fact that one formula works, but the other doesn't!
So this Sub works (where the last line adds and drags the formula : "=IFERROR((AY16/K16)-AF16,"""")"
But the formula at the end of the second Sub isn't being accepted by the VB editor?
I tried to replace the single quotes with double quotes, but that didn't work? Is there any obvious reason why the VB editor wouldn't accept it?
Code:
Workbooks(Main sheet).Sheets("Main sheet").Range("DD16").Formula = Workbooks(This_Bk).Sheets("Data").Range("P2").Formula
Dim rowBottom As Integer
rowBottom = Range("DC" & Rows.Count).End(xlUp).Row
Range("DD16:DD" & rowBottom).Formula = "=IFERROR((AY16/K16)-AF16,"""")"
But this one doesn't?
Code:
Workbooks(Main sheet).Sheets("Main sheet").Range("DD16").Formula = Workbooks(This_Bk).Sheets("Data").Range("P2").Formula
Dim rowBottom As Integer
rowBottom = Range("DC" & Rows.Count).End(xlUp).Row
Range("DD16:DD" & rowBottom).Formula = "=IFERROR(IF(H16="""","""",IF(BJ16="DIA",(((((IF(BG16="MINER",(IF(AND(BI16="FSA (CUMUL)",(OR(BF16="DATA",BF16="UNIT"))),(((AU16/K16)/L16)-(BE16/T16)),IF(AND(BI16="ABC",BF16="DATA"),((((AU16/K16)/L16)-( BE16/T16)/K16)),IF(AND(BI16="ABC",BF16="Pack"),(((AU16/K16)/L16)-(BE16/K16)),"CHECK/FETCH")))),IF(BG16="GBP",(IF(AND(BI16="FSA (CUMUL)",(OR(BF16="DATA",BF16="UNIT"))),((((AU16/K16)/L16)-(BE16/T16))*BH16),IF(AND(BI16="ABC",BF16="DATA"),(((AU16/K16)/L16)* BH16-((BE16/T16)/K16)),IF(AND(BI16="ABC",BF16="PACK"),((((AU16/K16)/L16)-(BE16/K16))*BH16),"CHECK/FETCH"))))))))))),((((IF(BG16="MINER",(IF(AND(BI16="FSA (CUMUL)",(OR(BF16="DATA",BF16="UNIT"))),((AU16/K16)-(BE16/T16)),IF(AND(BI16="ABC",BF16="DATA"),(((AU16/K16)-(BE16/T16)/K16)),IF(AND(BI16="ABC",BF16="Pack"),((AU16/K16)-(BE16/K16)),"CHECK/FETCH")))),IF(BG16="GBP",(IF(AND(BI16="FSA (CUMUL)",(OR(BF16="DATA",BF16="UNIT"))),(((AU16/K16)-(BE16/T16))*BH16),IF(AND(BI16="ABC",BF16="DATA"),((AU16/K16)*BH16-((BE16/T16)/K16)),IF(AND(BI16="ABC",BF16="PACK"),(((AU16/K16)-(BE16/K16))*BH16),"CHECK/FETCH")))))))))))),"""")"