I want to create a vlookup calculation in a cell using code. The problem is that the range used in the vlookup calculation can change. Therefore I need to select a range of cells and then use this range in a variable to be inserted into the line of code that contains the calcualtion.
I know that the code to set up the vlookup calcualtion is;
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC1,Sheet2!R2C1:R138C4,2,FALSE)"
but this only works for a fixed range of Sheet2!R2C1:R138C4
So far I've got...
Sheets("Sheet2"
.Range("a2"
.Select
Selection.CurrentRegion.Select
...to select my varying range
What I need to know is how to set this range as a variable that I can then insert into my line of code containing the calcualtion.
Thanks,
I know that the code to set up the vlookup calcualtion is;
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC1,Sheet2!R2C1:R138C4,2,FALSE)"
but this only works for a fixed range of Sheet2!R2C1:R138C4
So far I've got...
Sheets("Sheet2"
Selection.CurrentRegion.Select
...to select my varying range
What I need to know is how to set this range as a variable that I can then insert into my line of code containing the calcualtion.
Thanks,