简体   繁体   English

在单元格 VBA 中粘贴公式时出现 VBA 错误 1004

[英]VBA Error 1004 on pasting Formula in cells VBA

I'm getting error 1004 when trying to enter a formula using VBA:尝试使用 VBA 输入公式时出现错误 1004:

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().这是您的公式用缩进标记 SUMIFS() 中缺少的属性。 You can use a site like This one to format your ugly formulas automatically which really helps identifying errors like this.你可以使用像This one这样的网站来自动格式化你丑陋的公式,这真的有助于识别这样的错误。

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:假设这里的缺失值是RC3 ,这个更新后的公式应该可以工作:

=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))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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