How to invoke VLookUp function in Excel VBA. [Closed]

Report
-
Posts
2776
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
July 26, 2021
-
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.


1 reply

Posts
2776
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
July 26, 2021
465
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

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!