Nested IF and Match issue

andrewlau2881

New Member
Joined
Oct 20, 2023
Messages
15
Office Version
  1. 365
Platform
  1. Windows
Hi all,

Excel Formula:
=IF(MATCH(K2,A3:A33,0),1,IF((MATCH(K2,B3:B33,0)),2,""))

I would like to search through columns A and B to match a name.

If that name is found then I would like to return 1 if it is in column A and 2 if it is in column B.

It returns a 1 if it is in column A. However, if it is in column B I get N/A. I have used very similar IF statments before with success but cannot get my head around why this one won't work.

All help appreciated.
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
If it's not in column A, the first MATCH will return #N/A, and hence the formula will return #N/A.

One way to fix it: =IF(ISNUMBER(MATCH(K2,A3:A33,0)),1,IF(ISNUMBER(MATCH(K2,B3:B33,0)),2,""))

Or with Excel 365, you could say: =LET(m,MIN(IF(A2:B33=K2,{1,2})),IF(m=0,"",m))
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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