Combining if and vlookup functions

SONART

New Member
Joined
Aug 18, 2010
Messages
43
Hi All,

I'm trying to put together a formula combining "if" and "vlookup" statements.

I have a number of lookupvalues in the following cells which I want to look and derive from a list of codes in column H:

A B C
1 200A 200B 200C

I tried the following formula but for some reason it's not working:

=if(vlookup(A1,H:H,1,false)=A1,A1,if(vlookup(B1,H:H,1,false)=B1,B1,if(vlookup(C1,H:H,1,false)=C1,C1)

It only works if there is a match in cell A1 but if there is no match it's not matching values in cells B1 and C1.

Could someone please help.

Many Thanks,
SONART
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Hi All,

I'm trying to put together a formula combining "if" and "vlookup" statements.

I have a number of lookupvalues in the following cells which I want to look and derive from a list of codes in column H:

A B C
1 200A 200B 200C

I tried the following formula but for some reason it's not working:

=if(vlookup(A1,H:H,1,false)=A1,A1,if(vlookup(B1,H:H,1,false)=B1,B1,if(vlookup(C1,H:H,1,false)=C1,C1)

It only works if there is a match in cell A1 but if there is no match it's not matching values in cells B1 and C1.

Could someone please help.

Many Thanks,
SONART

You could try and add an ISNA constraint, something like:

=IF(ISNA(if(vlookup(A1,H:H,1,false)=A1,A1,if(vlookup(B1,H:H,1,false)=B1,B1,if(vlookup(C1,H:H,1,false)=C1,C1)),(vlookup(A1,H:H,1,false)=A1,A1,if(vlookup(B1,H:H,1,false)=B1,B1,if(vlookup(C1,H:H,1,false)=C1,C1),"N/A")
 
Upvote 0
Hi

It only works if there is a match in cell A1 but if there is no match it's not matching values in cells B1 and C1.

If the first VLookup() is not successful then it returns an error, and you are not dealing with it, like Benjamin is doing.

Another option:

=IF(COUNTIF(H:H,A1),A1,IF(COUNTIF(H:H,B1),B1,IF(COUNTIF(H:H,C1),C1,"N/A")))
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,589
Messages
6,179,744
Members
452,940
Latest member
rootytrip

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top