Ramesh PS
Ramesh PS

Reputation: 1

Dynamic VLOOKUP in VBA

I want a formula in a cell like below

=VLOOKUP(B3,Release!A:B,2,FALSE) </i>

for that I am using the below VBA code.

    lookup_cell = "B" & I
Formula_cell = "=VLOOKUP(" & lookup_cell & ",Release!A:B" & ",2,FALSE)"
    ActiveCell.FormulaR1C1 = Formula_cell

But I am getting the formula like below

=VLOOKUP('B3',Release!A:(B),2,FALSE)

Kindly help me to understand why i am getting the single quotes around B3 and why i am getting brakes around B.?

Upvotes: 0

Views: 54

Answers (1)

Rory
Rory

Reputation: 34035

Your formula is not in R1C1 format, so you shouldn't use the FormulaR1C1 property but rather use Formula instead:

ActiveCell.Formula = Formula_cell

Upvotes: 1

Related Questions