【问题标题】:I am using Sumif function in macro but the result is not getting我在宏中使用 Sumif 函数,但结果没有得到
【发布时间】:2014-04-14 11:47:04
【问题描述】:

我已经使用下面的代码来得到答案。我在所需位置得到结果,但未显示总和。

Cells(lastrow, 2).Offset(3, 1).Value = "=Sumif(L4:L" & lastrow & "," & "NEW ALBERTSONS INC" & ",J4:J" & lastrow - 1 & ")"

谁能帮我解决一下。

【问题讨论】:

    标签: excel vba macos


    【解决方案1】:

    试试这个:

    Cells(lastrow, 2).Offset(3, 1).Formula = "=SUMIF(L4:L" & lastrow & "," & """NEW ALBERTSONS INC""" & ",J4:J" & lastrow & ")"
    

    一些注意事项:

    • 我正在使用"""NEW ALBERTSONS INC""" 而不是"NEW ALBERTSONS INC" (你应该在构造 excel 公式时转义你的引号 通过 vba)
    • sum_rangecriteria_range 应该有相同的尺寸,那就是 为什么你应该使用L4:L" & lastrowJ4:J" & lastrow(或& lastrow-1 用于这两个范围)
    • 实际上,您可以通过将"," & """NEW ALBERTSONS INC""" 更改为", ""NEW ALBERTSONS INC""" 来稍微简化您的公式

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-08-13
    • 2021-10-08
    • 1970-01-01
    • 2016-08-07
    • 1970-01-01
    • 1970-01-01
    • 2015-11-23
    • 2022-11-01
    相关资源
    最近更新 更多