保存并重新打开后,excel公式停止工作

时间:2013-10-24 13:02:46

标签: excel-formula excel-2010

我有一个excel公式,根据另一张表中的数据执行公式。当我设置它时,一切都像梦一样,数据在主页上更新。我保存并关闭了。现在,当我打开它并更新数据时,公式给出了#error

=COUNTIFS('G:\Call\[File_name_test.xlsx]CPC-Mas Nov 2013'!$M$28:$M$67,"R", 'G:\Call\[File_name_test.xlsx]CPC-Mas Nov 2013'!$C$28:$C$67, "JAC")

我用谷歌搜索了它,但是excel不是我最强的!!请帮忙!

1 个答案:

答案 0 :(得分:1)

您无法使用该公式引用已关闭工作簿中的数据。

See alternative ways of referencing data in closed workbooks.

Sub ExecMacro4Excel()
    Dim path As String
    Dim workbookName As String
    Dim worksheetName As String
    Dim cell As String
    Dim returnedValue As String

    path = "C:\Users\" & Environ$("username") & "\Desktop\"
    workbookName = "book2.xlsm"
    worksheetName = "Sheet1"
    cell = "A1"

    returnedValue = "'" & path & "[" & workbookName & "]" & _
          worksheetName & "'!" & Range(cell).Address(True, True, -4150)

    MsgBox ExecuteExcel4Macro(returnedValue)
End Sub