0

I'm trying to use the following formula, but am getting the error application defined or object defined error. I have a feeling it's due to the line break, but it looks good to me.

ActiveCell.FormulaR1C1 = _
        "=IF(AND(R[1]C[-13]=RC[-13],R[1]C[-15]=RC[-15]),IF(AND(R[1]C[-8]=RC[-8],R[1]C[-3]<>RC[-3]),IF(AND(R[2]C[-8]=R[1]C[-8],R[2]C[-3]<>R[1]C[-3]),IF(AND(R[3]C[-8]=R[2]C[-8],R[3]C[-3]<>R[2]C[-3]),IF(AND(R[4]C[-13]=R[3]C[-13],R[4]C[-15]=R[3]C[-15]),"""",RC[-3]),IF(AND(R[3]C[-13]=R[2]C[-13],R[3]C[-15]=R[2]C[-15]),"""",RC[-3]))," & _
        "IF(AND(R[2]C[-13]=R[1]C[-13],R[2]C[-15]=R[1]C[-15],"""",RC[-3])),""""),IF(RC[-3]="""","""",RC[-3]))"
BigBen
  • 46,229
  • 7
  • 24
  • 40
  • 1
    The first part of the last line `"IF(AND(R[2]C[-13]=R[1]C[-13],R[2]C[-15]=R[1]C[-15],"""",RC[-3]` is missing a closing parenthesis for the AND part. Try `"IF(AND(R[2]C[-13]=R[1]C[-13],R[2]C[-15]=R[1]C[-15]),"""",RC[-3]` instead – barrowc Jul 28 '19 at 03:33
  • 3
    If you `Debug.Print` the formula and then try pasting it into the cell you may get more-useful information about where the problem is. – Tim Williams Jul 28 '19 at 05:41
  • Turn the macro recorder on and then write formula in required cell. You should get what you want. – shrivallabha.redij Jul 28 '19 at 08:30
  • 1
    @barrowc is right, after adding the missing parenthesis the formula worked fine for me. – Justyna MK Jul 28 '19 at 17:35
  • The parenthesis did it! Thanks! – Mike Blackman Jul 28 '19 at 23:20

0 Answers0