PDA

View Full Version : VBA R1C1 help on vlook up



malleshg24
10-09-2019, 07:56 PM
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

Aflatoon
10-10-2019, 02:20 AM
Like this:


Range("g2").FormulaR1C1 = "=VLOOKUP(RC" & namecol & ",R1C13:R15C18,3,0)"

malleshg24
10-10-2019, 12:40 PM
Hi Aflatoon,

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

Regards,
mg