I have the following nightmare (line breaks added for legibility):
The idea is to enter a different formula into a specified column of a spreadsheet depending on the value in the corresponding row in column D.
The above would work fine, except that some of the formulas are simple formulas and some are array formulas. The array formulas cause an error when the VBA code gets to this line. I tried using "Sheet2.Range(.Cells(5, i + 11), .Cells(lastRow, i + 11)).FormulaArray =" but that also threw an error. I also tried enclosing the array formulas in curly brackets but that didn't work either. Can anyone help?
Code:
Sheet2.Range(.Cells(5, i + 11), .Cells(lastRow, i + 11)).Formula = _
"=CHOOSE(MATCH(RC4,""No Category Defined"",
""No MCO"",
""MCO – PB thru FFS"",
""MCO – PB thru MCO – Sub – Sep"",
""MCO – PB thru MCO – Sub – Comb"",
""MCO – PB thru MCO – Not Sub"",
""MCO – PB through FFS & MCO – Sub – Sep"",
""MCO – PB through FFS & MCO – Sub – Comb"",
""MCO – PB through FFS & MCO – Not Sub "",0),
0, RC[-4], RC[-4], RC[-4],
RC[-5] * AVERAGE(IF(C4=""MCO – PB thru MCO – Sub – Sep"", C[-2]:C[-2])),
(RC[-5] * (AVERAGE(IF(C4=""MCO – PB thru MCO – Sub – Sep"", C[-2]:C[-2])))) / (1-(AVERAGE(IF(C4=""MCO – PB thru MCO – Sub – Sep"", C[-2]:C[-2])))),
RC[-4],
RC[-5] * (AVERAGE(IF(C4=""MCO – PB through FFS & MCO – Sub – Sep"", C[-2]:C[-2]))),
(RC[-5] * (AVERAGE(IF(C4=""MCO – PB through FFS & MCO – Sub – Sep"", C[-2]:C[-2])))) / (1-(AVERAGE(IF(C4=""MCO – PB through FFS & MCO – Sub – Sep"", C[-2]:C[-2])))))"
The idea is to enter a different formula into a specified column of a spreadsheet depending on the value in the corresponding row in column D.
The above would work fine, except that some of the formulas are simple formulas and some are array formulas. The array formulas cause an error when the VBA code gets to this line. I tried using "Sheet2.Range(.Cells(5, i + 11), .Cells(lastRow, i + 11)).FormulaArray =" but that also threw an error. I also tried enclosing the array formulas in curly brackets but that didn't work either. Can anyone help?