goodysgotacuda
Board Regular
- Joined
- Jun 27, 2014
- Messages
- 51
I am trying to apply a formula to a series of cells and recorded the process using the Record Macro method.
The function itself works just fine when I record the Macro, but when I try to run the Excel-Generated code I get a "Application-Defined or Object-Defined Error". I am not sure how Excel would make it's own Macro improperly, but it sure did.
The code that was generated is as follows, I am referencing 1 column as the cells move down and also a table with fixed cell addresses. I assume this is why the generated code varies between the RC[] type reference and the RxCy method of referencing cells.
It is a function that was generated and is a summation of constants multiplied up the 16th power as the table continues, which is why it's so elaborate. I can't seem to change up this code to get it to apply to my series of cells. Any recommendations?
Thank you!
The function itself works just fine when I record the Macro, but when I try to run the Excel-Generated code I get a "Application-Defined or Object-Defined Error". I am not sure how Excel would make it's own Macro improperly, but it sure did.
The code that was generated is as follows, I am referencing 1 column as the cells move down and also a table with fixed cell addresses. I assume this is why the generated code varies between the RC[] type reference and the RxCy method of referencing cells.
Code:
ActiveCell.FormulaR1C1 = _
"=IF(AND(R[-6]C[-2]<=1300,R[-6]C[-2]>=1000),1650,(R10C21*R[-6]C[-2]^R10C20)+(R11C21*R[-6]C[-2]^R11C20)+(R12C21*R[-6]C[-2]^R12C20)+(R13C21*R[-6]C[-2]^R13C20)+(R14C21*R[-6]C[-2]^R14C20)+(R15C21*R[-6]C[-2]^R15C20)+(R16C21*R[-6]C[-2]^R16C20)+(R17C21*R[-6]C[-2]^R17C20)+(R18C21*R[-6]C[-2]^R18C20)+(R19C21*R[-6]C[-2]^R19C20)+(R20C21*R[-6]C[-2]^R20C20)+(R21C21*R[-6]C[-2]^R21C" & _
"C21*R[-6]C[-2]^R22C20)+(R23C21*R[-6]C[-2]^R23C20)+(R24C21*R[-6]C[-2]^R24C20)+(R25C21*R[-6]C[-2])+R26C21)"
It is a function that was generated and is a summation of constants multiplied up the 16th power as the table continues, which is why it's so elaborate. I can't seem to change up this code to get it to apply to my series of cells. Any recommendations?
Thank you!