Home Excel Powerpoint Word Outlook Error Codes

VBA Useful Codes

Welcome to the World of VBA
Home > VBAUsefulCodes

VLookup using VBA


We are using the Vlookup function in excel. The same thing can be achieved using excel vba. Here is the sample code provided below. Considering you have A:B have data (Fruit Name & Fruit Color) in sheet1.

Sub vlookup_VBA()

    Dim fruit_name As String
    fruit_name = "lemon"
    fruit_color = Application.WorksheetFunction.VLookup(fruit_name, Sheet1.Range("A:B"), 2, False)
    MsgBox "Fruit Color  is : " & fruit_color

End Sub

Subscribe

Enter your e-mail below and get notified on the latest blog posts.




Tags

VBA Outlook KPI Excel Alt+F11 Dashboards Macros Recording Graphs Automation Developer WaterFall Powerpoint Charts Pivot Tables Forecast Charts


Follow Us