SASUSMC
SASUSMC

Reputation: 681

VBA If function with Vlookup

I am trying to use a formula that states the following:

If A4 = T Then Vlookup Else Vlookup2

Here is what I have written that it does not like.

=IF(A4 = "T","=VLOOKUP(I4,treatlookup,11,FALSE)","=VLOOKUP(I4,itemlookup,22,FALSE)")

I tried without the quotes around the =Vlookup but it does not accept that either, gives an error.

Any suggestions would be appreciated.

Thanks,

Upvotes: 0

Views: 103

Answers (1)

xlm
xlm

Reputation: 7594

You don't set the value as you would typing in the formula into the cell. Removing the " and = should resolve your problem:

=IF(A4="T",VLOOKUP(I4,treatlookup,11,FALSE),VLOOKUP(I4,itemlookup,22,FALSE))

Upvotes: 1

Related Questions