此代码有什么问题?不断收到应用程序定义的错误

时间:2019-01-03 06:32:58

标签: excel vba excel-formula

保持提示应用程序定义的错误,我不认为有任何错误

ActiveSheet.Cells(salesNo + 1, 5).Formula = "=CONCATENATE(""Subtotal for ""& Cells(salesNo - 1, 3).Address)"

2 个答案:

答案 0 :(得分:1)

ActiveSheet.Cells(salesNo + 1, 5).Formula = _
      "=""Subtotal for "" & " & Cells(salesNo - 1, 3).Address

答案 1 :(得分:0)

Excel中的地址

ActiveSheet.Cells(salesNo + 1, 5).Formula _
    = "=""Subtotal for ""&ADDRESS(" & salesNo - 1 & ",3)"

ActiveSheet.Cells(salesNo + 1, 5).Formula = "=" & Chr(34) _
    & "Subtotal for " & Chr(34) & "&ADDRESS(" & salesNo - 1 & ",3)"

摆脱$符号:

ActiveSheet.Cells(salesNo + 1, 5).Formula _
    = "=""Subtotal for ""&ADDRESS(" & salesNo - 1 & ",3,4)"

ActiveSheet.Cells(salesNo + 1, 5).Formula = "=" & Chr(34) _
    & "Subtotal for " & Chr(34) & "&ADDRESS(" & salesNo - 1 & ",3,4)"

编辑

ActiveSheet.Cells(salesNo + 1, 5).Formula _
    = "=""Subtotal for ""&INDIRECT(ADDRESS(" & salesNo - 1 & ",3,4))"

ActiveSheet.Cells(salesNo + 1, 5).Formula = "=" & Chr(34) _
    & "Subtotal for " & Chr(34) & "&INDIRECT(ADDRESS(" & salesNo - 1 & ",3,4))"