索引从已关闭的工作簿与可变文件路径匹配

时间:2016-05-11 17:40:59

标签: excel vba excel-vba

我目前有以下内容,因为它引用了打开的TypeList工作簿,并在两个条件上匹配以返回适当的值。

With Sheets(wsname)
        .Range("N2").FormulaArray = "=INDEX([TypeList]List!$B$2:$D$1000,MATCH(1,([TypeList]List!$B$2:$B$1000=K2)*([TypeList]List!$A$2:$A$1000=""CVA""),0),3)"
        .Range("N2:N" & lRow).FillDown
End With

我尝试的是避免打开TypeList工作簿,而是引用已关闭工作簿中的范围。我已经分配了文件路径和范围

sPath = Application.UserLibraryPath
sPath2 = Application.UserLibraryPath
sPath3 = Application.UserLibraryPath
sPath = sPath & "[TypeList]List'!$B$2:$D$1000"
sPath2 = sPath2 & "[TypeList]List'!$A$2:$A$1000"
sPath3 = sPath3 & "[TypeList]List'!$B$2:$B$1000"

所以我认为这会起作用

.Range("N2").FormulaArray = "=INDEX(sPath,MATCH(1,(sPath3=K2)*(sPath2=""CVA""),0),3)"

只返回#NAME,所以我假设它没有看到已关闭的工作簿,但我确定要走哪条路。

0 个答案:

没有答案