简体   繁体   中英

VBA Error 1004 on pasting Formula in cells VBA

I'm getting error 1004 when trying to enter a formula using VBA:

SIOP_sh.Range("E4").FormulaR1C1 = "=IF(SUMIFS(ALCZ_JI_PMD!R3C13:R10002C13,ALCZ_JI_PMD!R3C31:R10002C31,RC3,ALCZ_JI_PMD!R3C11:R10002C11,R1C)=0, IF((SUMIFS(ALCZ_JI_PMD!R3C14:R10002C14,ALCZ_JI_PMD!R3C31:R10002C31,RC3,ALCZ_JI_PMD!R3C11:R10002C11,R1C)=SUMIFS(ALCZ_JI_PMD!R3C23:R10002C23,ALCZ_JI_PMD!R3C31:R10002C31,RC3,ALCZ_JI_PMD!R3C11:R10002C11,R1C)),SUMIFS(ALCZ_JI_PMD!R3C14:R10002C14,ALCZ_JI_PMD!R3C31:R10C3,ALCZ_JI_PMD!R3C11:R10002C11,R1C),SUMIFS(ALCZ_JI_PMD!R3C23:R10002C23,ALCZ_JI_PMD!R3C31:R10002C31,RC3,ALCZ_JI_PMD!R3C11:R10002C11,R1C)),SUMIFS(ALCZ_JI_PMD!R3C13:R10002C13,ALCZ_JI_PMD!R3C31:R10002C31,RC3,ALCZ_JI_PMD!R3C11:R10002C11,R1C))"

I used a similar formula before but for this formula above, I'm continuously getting the syntax error. Can you kindly help me with this?

Here is your formula blown out with indention marking the missing attribute in your SUMIFS(). You can use a site like This one to format your ugly formulas automatically which really helps identifying errors like this.

IF(
    SUMIFS(
        ALCZ_JI_PMD!R3C13:R10002C13,
        ALCZ_JI_PMD!R3C31:R10002C31,
        RC3,
        ALCZ_JI_PMD!R3C11:R10002C11,
        R1C
    )=0,
    IF(
        (
            SUMIFS(
                ALCZ_JI_PMD!R3C14:R10002C14,
                ALCZ_JI_PMD!R3C31:R10002C31,
                RC3,
                ALCZ_JI_PMD!R3C11:R10002C11,
                R1C
            )=
            SUMIFS(
                ALCZ_JI_PMD!R3C23:R10002C23,
                ALCZ_JI_PMD!R3C31:R10002C31,
                RC3,
                ALCZ_JI_PMD!R3C11:R10002C11,
                R1C
            )
        ),
        SUMIFS(
            ALCZ_JI_PMD!R3C14:R10002C14,
            ALCZ_JI_PMD!R3C31:R10C3,
            ##################MISSING CONDITION FOR SUMIF HERE##############
            ALCZ_JI_PMD!R3C11:R10002C11,
            R1C
        ),
        SUMIFS(
            ALCZ_JI_PMD!R3C23:R10002C23,
            ALCZ_JI_PMD!R3C31:R10002C31,
            RC3,
            ALCZ_JI_PMD!R3C11:R10002C11,
            R1C
        )
    ),
    SUMIFS(
        ALCZ_JI_PMD!R3C13:R10002C13,
        ALCZ_JI_PMD!R3C31:R10002C31,
        RC3,
        ALCZ_JI_PMD!R3C11:R10002C11,
        R1C
    )
)

Assuming that the missing value here is RC3 , this updated formula should work:

=IF(SUMIFS(ALCZ_JI_PMD!R3C13:R10002C13,ALCZ_JI_PMD!R3C31:R10002C31,RC3,ALCZ_JI_PMD!R3C11:R10002C11,R1C)=0,IF((SUMIFS(ALCZ_JI_PMD!R3C14:R10002C14,ALCZ_JI_PMD!R3C31:R10002C31,RC3,ALCZ_JI_PMD!R3C11:R10002C11,R1C)=SUMIFS(ALCZ_JI_PMD!R3C23:R10002C23,ALCZ_JI_PMD!R3C31:R10002C31,RC3,ALCZ_JI_PMD!R3C11:R10002C11,R1C)),SUMIFS(ALCZ_JI_PMD!R3C14:R10002C14,ALCZ_JI_PMD!R3C31:R10C3,RC3,ALCZ_JI_PMD!R3C11:R10002C11,R1C),SUMIFS(ALCZ_JI_PMD!R3C23:R10002C23,ALCZ_JI_PMD!R3C31:R10002C31,RC3,ALCZ_JI_PMD!R3C11:R10002C11,R1C)),SUMIFS(ALCZ_JI_PMD!R3C13:R10002C13,ALCZ_JI_PMD!R3C31:R10002C31,RC3,ALCZ_JI_PMD!R3C11:R10002C11,R1C))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM