How to invoke VLookUp function in Excel VBA.

Closed
Wingie - Mar 15, 2016 at 05:19 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Mar 15, 2016 at 12:21 PM
Hello,
Please, I need a visual basic code that can actually invoke or call a V Lookup
function in Excel to query data in two separate worksheets and match same data in each worksheet automatically.

Kind Regards,
Wingie.


Related:

1 response

TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 552
Mar 15, 2016 at 12:21 PM
Hi Wingie,

When the matrix is located in sheet 2 A1:B5, the value to look up is in sheet1 A1 and the result in sheet1 B1, then the code will look like this:
Sub RunMe()
Sheets("Sheet1").Range("B1").Value = Application.WorksheetFunction. _
VLookup(Sheets("Sheet1").Range("A1"), Sheets("Sheet2").Range("A1:B5"), 2)
End Sub


Best regards,
Trowa

0