Compile error end of statement

  • ActiveCell.FormulaR1C1 = " =SUMPRODUCT(SUBTOTAL(3,OFFSET(R[4]C[-2]:R[14995]C[-2],ROW(R[4]C[-2]:R[14995]C[-2])-ROW(R[4]C[-2]),0,1)),--(R[4]C[-2]:R[14995]C[-2]="(XXXXX)"))
    SUMPRODUCT(SUBTOTAL(3,OFFSET(R[4]C[-2]:R[14995]C[-2],ROW(R[4]C[-2]:R[14995]C[-2])-ROW(R[4]C[-2]),0,1)),--(R[4]C[-2]:R[14995]C[-2]="(XXXXXXXXX.)"))
    SUMPRODUCT(SUBTOTAL(3,OFFSET(R[4]C[-2]:R[14995]C[-2],ROW(R[4]C[-2]:R[14995]C[-2])-ROW(R[4]C[-2]),0,1)),--(R[4]C[-2]:R[14995]C[-2]="(XXXXXXXXXXX"))
    SUMPRODUCT(SUBTOTAL(3,OFFSET(R[4]C[-2]:R[14995]C[-2],ROW(R[4]C[-2]:R[14995]C[-2])-ROW(R[4]C[-2]),0,1)),--(R[4]C[-2]:R[14995]C[-2]="(XXXXXX)"))
    SUMPRODUCT(SUBTOTAL(3,OFFSET(R[4]C[-2]:R[14995]C[-2],ROW(R[4]C[-2]:R[14995]C[-2])-ROW(R[4]C[-2]),0,1)),--(R[4]C[-2]:R[14995]C[-2]="(XXXXXX)"))
    SUMPRODUCT(SUBTOTAL(3,OFFSET(R[4]C[-2]:R[14995]C[-2],ROW(R[4]C[-2]:R[14995]C[-2])-ROW(R[4]C[-2]),0,1)),--(R[4]C[-2]:R[14995]C[-2]="(XXXXXX)"))
    SUMPRODUCT(SUBTOTAL(3,OFFSET(R[4]C[-2]:R[14995]C[-2],ROW(R[4]C[-2]:R[14995]C[-2])-ROW(R[4]C[-2]),0,1)),--(R[4]C[-2]:R[14995]C[-2]="(XXXXXXXXX)"))
    SUMPRODUCT(SUBTOTAL(3,OFFSET(R[4]C[-2]:R[14995]C[-2],ROW(R[4]C[-2]:R[14995]C[-2])-ROW(R[4]C[-2]),0,1)),--(R[4]C[-2]:R[14995]C[-2]="(XXXXX)"))"


    Here is my code. Ignore the X's but I keep receiving compile errors and not sure whats going on. Can anyone help?


    Thanks in advance

  • Can you attach the workbook? I can't use that snippet without seeing the rest of the code, is it one line of code/


    Why do you need to add the formula with VBA?

  • You need to double up any quotes that are in the actual formula, but your formula as posted doesn't appear to be valid.

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!