Consulting

Results 1 to 3 of 3

Thread: VBA R1C1 help on vlook up

  1. #1
    Banned VBAX Contributor
    Joined
    Aug 2017
    Posts
    144
    Location

    VBA R1C1 help on vlook up

    Hi Team,
    
    
    Please help how to pass variable NameCol = 2. in R1C1 Formula,
    =VLOOKUP(RC[-5]  here I want (-5) it Dynamic. 
    
    
    Dim nameCol As Long
    nameCol = Application.WorksheetFunction.Match("Name", Range("1:1"), 0)
    nameCol = 2
    
    
    Range("g2").FormulaR1C1 = "=VLOOKUP(RC[-5],R1C13:R15C18,3,0)"
    Range("g2").FormulaR1C1 = "=VLOOKUP(RC[-5],R1C11:R9C15,2,0)"
        
    '=VLOOKUP(B2,$K$1:$O$9,2,0)
        
    
    
    Thanks in Advance for your help.
    
    
    Regards,
    mg

  2. #2
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,720
    Location
    Like this:

    Range("g2").FormulaR1C1 = "=VLOOKUP(RC" & namecol & ",R1C13:R15C18,3,0)"
    Be as you wish to seem

  3. #3
    Banned VBAX Contributor
    Joined
    Aug 2017
    Posts
    144
    Location
    Hi Aflatoon,

    It worked , Thank you so much for for your help!

    Regards,
    mg

Posting Permissions

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