从封闭的工作簿中获取数据并分配给变量

时间:2019-06-14 11:45:26

标签: excel vba

我正在使用以下代码从已关闭的工作簿中检索一个号码。 MsgBox返回正确的值,但是我无法将该数字分配给我的modelVersion变量,并且不明白为什么会这样。如果有人认为我不能以这种方式使用ExecuteExcel4Macro方法,我将不胜感激。

Public Sub checkModelVersion()

    Dim wbPath As String, wbName As String
    Dim wsName As String, cellRef As String
    Dim Ret As String

    wbPath = "C:\mypath\"

    wbName = "Update.xlsm"
    wsName = "Dashboard"
    cellRef = "E7"

    Ret = "'" & wbPath & "[" & wbName & "]" & wsName & "'!" & Range(cellRef).Address(True, True, -4150)

    MsgBox ExecuteExcel4Macro(Ret)
    modelVersion = ExecuteExcel4Macro(Ret)

End Sub

0 个答案:

没有答案