How to use "This Row" in VBA VLOOKUP?

I am trying to modify the Vlookup function to use the "this line" functionality. For example, I have a macro that puts the following formula in column B:

= VLOOKUP (I1253, treatlookup, 11, FALSE)

This works well, however during the macro I need to switch it to a different formula:

= VLOOKUP (I1253, Itemlookup, 22, FALSE)

Of course, the data changes every time, so I can’t just include this formula in a specific cell. So I would like the formula to be indicated

= Vlookup (I "CurrentRow", ItemLookup, 22, False)

Then I can use the if statement to determine which of the two formulas to use.

thanks in Advance Using Excel 2010.

0
source share
1 answer

Use the R1C1 style :

Activecell.FormulaR1C1 = "=VLOOKUP(RC9, ItemLookup, 22, false)"
+2
source

All Articles