我现在已经搜索了这个(和其他网站)几天,我放弃了自己尝试。 我的代码不想给我值:错误1004无法获取WorksheetFunction类的Vlookup属性。
我不想打开其他工作簿来获取这些值,因为我正在为其他人制作这张表,如果有些东西弹出,他们基本上就会惊慌失措。
代码如下: Sub CashHoldings() Dim RapportBok As Workbook 昏暗的RapportArk作为工作表 Dim TradeFile As Worksheet
Set RapportBok = Workbooks("Rapport kunder")
Set RapportArk = RapportBok.Sheets(1)
Set TradeFile = Workbooks("Trade File Master 1").Sheets("Trade file")
Dim wbPath As String, wbName As String
Dim wsName As String, cellRef As String
Dim Ret As String
Dim cash As Long
'wbPath = "F:\Oppgjør\Dagens trades\Dagen cash\"
wbPath = "F:\Oppgjør\Dagens trades\Dagen cash\"
wbName = RapportArk.Range("I2") & ".xlsx"
wsName = "Kontantbeholdning Makro"
cellRef = "L:N"
Ret = "'" & wbPath & "[" & wbName & "]" & _
wsName & "'!" & Range(cellRef).Address(True, True)
MsgBox Ret
cash = Application.WorksheetFunction.VLookup(RapportArk.Range("C2"), Ret, 2,
False)
End Sub
我在Ret下得到了正确的名字,即:'F:\Oppgjør\ Dagens trades \ Dagens cash [26.04.2017.xlsx] \ Kontantbeholdning Makro'!$ L:$ N
我错过了什么?
提前谢谢你:) 米尔