Vba Excel do vlookup from a closed file

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

Leave a Comment