+ Reply to Thread
Results 1 to 4 of 4

how to do a vlookup in vba?

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    12-03-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    107

    how to do a vlookup in vba?

    Hi guys,

    how do you execute a vlookup in vba? What i normally do is turn on the macro recorder and type the vlookup function then that's it. But my concern is that i dont want the formula to be seen when the macro is executed and people can see a glimpse of the formula if i use the macro recorder to perform a vlookup function. so for example:

     Sub testingggg()
    '
    ' Macro2 Macro
    '
    
       
        ActiveCell.Offset(0, 1).Range("A1").Select
        ActiveCell.FormulaR1C1 = _
            "=VLOOKUP(RC[-1],'C:\Users\Kevin\Desktop\FINAL preliminary release of estim program\[MASTER PRICELIST.xlsm]PRICELIST'!R1C1:R65536C43,2,FALSE)"
        ActiveCell.Select
        Selection.Copy
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
    End Sub
    how do you change that Activecell.formulaR1C1 line and make it into a legitimate vba code that when the user performs the macro it will be smooth and they wont catch a glimpse of the formula?

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,155

    Re: how to do a vlookup in vba?

     Sub testingggg()
    '
    ' Macro2 Macro
    ' 
    Application.ScreenUpdating=False
    With ActiveCell.Offset(0, 1)
        .FormulaR1C1 = _
            "=VLOOKUP(RC[-1],'C:\Users\Kevin\Desktop\FINAL preliminary release of estim program\[MASTER PRICELIST.xlsm]PRICELIST'!R1C1:R65536C43,2,FALSE)"
        .Value = .Value
    End With
    Application.ScreenUpdating=True
    End Sub

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Contributor
    Join Date
    12-03-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    107

    Re: how to do a vlookup in vba?

    No way, that simple???? will try it out and give you a star if it works.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,155

    Re: how to do a vlookup in vba?

    Yes,way. That simple. Thanks for the rep.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1