Vba Excel do vlookup from a closed file

后端 未结 2 1375
再見小時候
再見小時候 2020-11-28 16:56

I would like to do a vlookup from a close file to an active open file, The path of the closed file will be given as a variant

Lets say mypath = \"C:\\li

2条回答
  •  -上瘾入骨i
    2020-11-28 17:07

    You will need the full path.

    Example

    Option Explicit
    Public Sub Example()
        Dim Path As String
    
        Path = "C:\Temp\"
    
        With ThisWorkbook.Sheets("Sheet1")
            .Range("B1").Formula = "=VLOOKUP(A1,'" & Path & "[Book1.xlsx]Sheet2'!A:J,3,FALSE)"
        End With
    End Sub
    

    VLOOKUP function

提交回复
热议问题