ExcelPupper
Board Regular
- Joined
- Mar 2, 2020
- Messages
- 112
- Office Version
- 2019
- Platform
- Windows
Is it possible to use a variable on table_array for a Vlookup formula on vba?
Im trying to run my code below but it gives error.
Im trying to run my code below but it gives error.
VBA Code:
Sub LookUpData()
'
'
'
' Keyboard Shortcut: Ctrl+Shift+Q
'
Application.ScreenUpdating = False
Dim MyFile As String, MyWB As String, ws As Worksheet
MyLoc = "C:\Users\ADMIN\Desktop\Test\vba\"
MyWB = MyFile & "SourceData.xlsm"
Set ws = ThisWorkbook.Sheets("Data")
ws.Range("C1").Formula = "=VLOOKUP($A1,'MyWB'!$B:$D,3,FALSE)"
End Sub