【问题标题】:Excel VBA Sum FunctionExcel VBA求和函数
【发布时间】:2013-03-21 19:12:03
【问题描述】:

我在 vba 中遇到了行数公式的问题。 我正在使用下面的代码。当我检查Range("H3").Formula 中的值时,它给了我正确的值=SUM(C5:G5)

但问题是它没有反映在 excel 单元格中。

Range("H3").Formula = "=SUM(" & Range(Cells(5, 3), Cells(5, 7)).Address(False, False) & ")"

【问题讨论】:

  • 使用.value 而不是.formula

标签: excel sum excel-formula vba


【解决方案1】:

您需要完全限定单元格(注意点)。试试这个

'~~> Replace this with the relevant sheet
With Sheets("Sheet1")
    .Range("H3").Formula = "=SUM(" & _
                          .Range(.Cells(5, 3), .Cells(5, 7)).Address(False, False) & _
                          ")"
End With

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-08-24
    • 1970-01-01
    • 2012-07-27
    • 2018-06-30
    • 2017-04-16
    • 2018-03-10
    • 1970-01-01
    相关资源
    最近更新 更多