Combining columns with If

Usercode

Board Regular
Joined
Aug 18, 2017
Messages
107
Office Version
  1. 2016
Platform
  1. Windows
I have a range of columns (A1,B1,C1,D1). These columns have values from 1 to 20.
I have a formula in F1 like this:

Code:
=if($A1>7,"U",if($B1>7,"X",If($C1>7,"Y",if($D1>7,"Z",""))))

This formula puts the value of U,X,Y and Z if any of these cells (A1,B1,C1 or D1) is bigger than 7.

but it can't handle if there are two cells bigger than >7.

What should I add to this formula, if there are two numbers bigger than 7. So the end result will be a pair of U,X,Y or Z (comma separated).

Thanks.
 
Last edited:

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Try:

=IFERROR(LEFT(IF($A1>7,"U, ","")&IF($B1>7,"X, ","")&IF($C1>7,"Y, ","")&IF($D1>7,"Z, ",""),(COUNTIF($A1:$D1,">7")-1)*3+1),"")
 
Upvote 0
If you have a version of Excel that has the TEXTJOIN function, you could also try this. It is an array formula so should be entered without the {} but confirmed with Ctrl+Shift+Enter, not just Enter. If confirmed correctly, Excel will insert the {}. The formula can then be copied down.

Excel Workbook
ABCDE
158310X,Z
21010210U,X,Z
3
41234
520191817U,X,Y,Z
659Y
Join
 
Last edited:
Upvote 0
Thanks, Peter. Unfortunately, I don't have TextJoin function. I use Office 2007.
 
Upvote 0
Thanks, Peter. Unfortunately, I don't have TextJoin function. I use Office 2007.
Fair enough. :)


=IFERROR(LEFT(IF($A1>7,"U, ","")&IF($B1>7,"X, ","")&IF($C1>7,"Y, ","")&IF($D1>7,"Z, ",""),(COUNTIF($A1:$D1,">7")-1)*3+1),"")
You could simplify the removal of the extraneous comma & space, and avoid the need for IFERROR if the ", " is put before the letter each time.

=MID(IF($A1>7,", U","")&IF($B1>7,", X","")&IF($C1>7,", Y","")&IF($D1>7,", Z",""),3,99)
 
Upvote 0
Peter, A quick question, please.
I wanted to apply your formula some another table too. The formula I used is this:

Code:
=MID(IF($BA4>5,", E1","")&IF($BB4>5,", E2","")&IF($BC4>5,", E3","")&IF($BD4>5,", E4","")&IF($BE4>5,", E5","")&IF($BF4>5,", EE",""),3,99)

It work normally. but when any of the cells in the range is blank but with a formula which is
Code:
=IF(Intervals!$BV4=0,"",Intervals!$BV4)
, the formula counts it as if it is bigger than 5, and puts it in the result. Is there any way to get rid of this? please.
 
Upvote 0
Ok, I solved the problem. When I use the data on the main sheet, instead of reference sheet, it doesn't give the same error. Thanks.
 
Upvote 0
Deleted. Sorry, wrong response.

Edit: This is what I meant to post.
If you did have formulas returning "", then for the original question, a solution would be

=MID(IF(N($A1)>7,", U","")&IF(N($B1)>7,", X","")&IF(N($C1)>7,", Y","")&IF(N($D1)>7,", Z",""),3,99)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,197
Members
453,022
Latest member
RobertV1609

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