Formula R1C1 Macro Error 1004

Asked

Viewed 149 times

-1

I have a macro to apply a formula to some cells. To be able to have the formula in VBA format I recorded the macro to generate it, but when I ran the macro it runs error 1004...

U        Selection.FormulaR1C1 = _
        "=IF(AND(RC5=Infos!R2C4,RC9='Premissas Financeiras'!R6C2,RC3='Premissas Financeiras'!R2C3),(-RC16*'Premissas Financeiras'!R6C3), IF(AND(RC5=Infos!R2C4,RC9='Premissas Financeiras'!R7C2,RC3='Premissas Financeiras'!R2C3),(-RC16*'Premissas Financeiras'!R7C3), IF(AND(RC5=Infos!R2C4,RC9='Premissas Financeiras'!R6C2,RC3='Premissas Financeiras'!R2C4),(-RC16*'Premissas Financ" & _
        "6C4), IF(AND(RC5=Infos!R2C4,RC9='Premissas Financeiras'!R7C2,RC3='Premissas Financeiras'!R2C4),(-RC16*'Premissas Financeiras'!R7C4), IF(AND(RC5=Infos!R2C4,RC9='Premissas Financeiras'!R6C2,RC3='Premissas Financeiras'!R2C5),(-RC16*'Premissas Financeiras'!R6C5), IF(AND(RC5=Infos!R2C4,RC9='Premissas Financeiras'!R7C2,RC3='Premissas Financeiras'!R2C5),(-RC16*'Premissas F" & _
        "s'!R7C5),))))))"

If anyone can help me! I don’t know what else to do because the range is set. Thank you

  • Ines, Welcome to Stack Overflow in English. Please click on edit and translate the question.

1 answer

0

Copy the formula the way it’s on the spreadsheet. Example:

Range("C1").Formula = "=A1+B1"

Note that you do not have R1C1

  • The use of FormulaR1C1 is correct, since the notation A1 is not being used, but rather the relative rating reference R1C1. But I believe that the way to accomplish this according to your answer is the easiest.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.