Combining IF Functions

RaydenUK

Board Regular
Joined
Mar 25, 2014
Messages
74
How would I combine these 4 IF statements into one?

=IF(A2="A",IF(ISNUMBER(MATCH("B",$A$2:$A$21,0)),"B",A2),A2)
=IF(B2="D",IF(ISNUMBER(MATCH("E",$A$2:$A$21,0)),"E",B2),B2)
=IF(C2="L",IF(ISNUMBER(MATCH("O",$A$2:$A$21,0)),"O",C2),C2)
=IF(D2="F",IF(ISNUMBER(MATCH("K",$A$2:$A$21,0)),"K",D2),D2)

Any help would be greatly appreciated
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
It isn't very clear what you are trying to do. You cannot combine them all into one because each one returns a different value. If you those four formulas to return one string then that is accomplished very simply with this:

Code:
=IF(A2="A",IF(ISNUMBER(MATCH("B",$A$2:$A$21,0)),"B",A2),A2) & IF(B2="D",IF(ISNUMBER(MATCH("E",$A$2:$A$21,0)),"E",B2),B2) & IF(C2="L",IF(ISNUMBER(MATCH("O",$A$2:$A$21,0)),"O",C2),C2) & IF(D2="F",IF(ISNUMBER(MATCH("K",$A$2:$A$21,0)),"K",D2),D2)

Looks long and ugly but it works :)
 
Upvote 0
Thank you for the reply, but i just realized that i wrote the wrong formula

=IF(A2="A",IF(ISNUMBER(MATCH("B",$A$2:$A$21,0)),"B",A2),A2)
=IF(A2="D",IF(ISNUMBER(MATCH("E",$A$2:$A$21,0)),"E",A2),A2)
=IF(A2="L",IF(ISNUMBER(MATCH("O",$A$2:$A$21,0)),"O",A2),A2)
=IF(A2="F",IF(ISNUMBER(MATCH("K",$A$2:$A$21,0)),"K",A2),A2)

The problem when combining this formula with "&" is it returns multiple values in the cell instead of just a single value that means all 4 conditions.
 
Upvote 0
That makes more sense, the only logical combination I saw for your first four formulas was a combination with &.

I'm not entirely sure what you are trying to do but this seems like it might be what you want:

Code:
=IF(A2="A",IF(ISNUMBER(MATCH("B",$A$2:$A$21,0)),"B",A2),IF(A2="D",IF(ISNUMBER(MATCH("E",$A$2:$A$21,0)),"E",A2),IF(A2="L",IF(ISNUMBER(MATCH("O",$A$2:$A$21,0)),"O",A2),IF(A2="F",IF(ISNUMBER(MATCH("K",$A$2:$A$21,0)),"K",A2),A2))))

If you do not get the desired results, it would be helpful if you could provide an example of what you want to see happen. For example, if A2 is A and B isn't found in the range, do you want it to look for D, L, and F in the range?
 
Upvote 0

Forum statistics

Threads
1,223,239
Messages
6,170,947
Members
452,368
Latest member
jayp2104

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