Question

Let me preface by saying I'm very new to VBA and understand there could be easier, cleaner ways to go about this, but here we go:

I have this equation:

ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-3],R2C16:R188C16,1,FALSE)"
Selection.AutoFill Destination:=Range("Q2", "Q" & CellNumber), Type:=xlFillDefault   

It inserts A VLOOKUP equation and compares a column 3 columns over to a table array. It then autofills down to the CellNumber variable length.

The problem is that I want the table array length to be adjustable and use CellNumber in the VLOOKUP equation so that it changes accordingly.

But... I'm having no luck making it work...

Any help would be awesome.

Was it helpful?

Solution

This was acknowledged as a solution in the comments:

Range("Q2", "Q" & CellNumber).FormulaR1C1 = "=VLOOKUP(RC[-3],R2C16:R" & CellNumber & "C16,1,FALSE)"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top