Compare values from multiple columns - excel

I'm trying to compare values from multiple columns and then highlight the row if it matches my criteria using conditional formatting. For example: in the table below, there are four columns, and I want to compare the values within the the 3 columns: A-C. If they all match, then I want to highlight the entire row. When I use conditional formatting, I'm only able to compare two of the three. I don't know the syntax to compare more than columns.
A B C
Name Has Dog Has Cat Has Bird
A Y Y Y
B Y N Y
C Y Y N
D N N Y
E Y Y N

Please try:
=AND($B1=$C1,$B1=$D1)
for Format values where this formula is true: and Applies to all the columns you have available.

Related

Return Multiple Unique Matches in Excel without Array Formula

Given an Excel table of shape
Col. A Col B Col. C Col. D Col. E
x 2 x 2 3
x 3 y 7
y 7 z -5
x 2
z -5
I want to return the first unique hit in Column B for argument "x" in Column D,
the second unique hit in Column B for argument "x" in Column E and so forth.
The formula I'm currently using in cell D1 for this is
{=IFERROR(INDEX($B$1:$B$5,MATCH(0,COUNTIF($C1:C1,$B$1:$B$5)+($A$1:$A$5<>$C1),0)),"")}
which is working.
The problem I'm having is that since this is an array formula and since I'm analyzing a decent amount of data computation time for my sheet is too high.
Is there an alternative for this functionality avoiding an array formula?
Thanks!
Haven't got time to test this properly, but if you have Excel 365 you can use a single formula per row and it may be faster:
=TRANSPOSE(UNIQUE(FILTER(B1:B10,A1:A10=C1)))
in D1.
EDIT
To pull the formula down, you need static references as OP has pointed out. Probably should check for empty cells in column C as well, so formula becomes:
=IF(C1="","",TRANSPOSE(UNIQUE(FILTER(B$1:B$10,A$1:A$10=C1))))

Return an array of True/False based on two columns meeting a criteria

I would like to adjust the following CSE formula to return an array of Booleans for each row should the criteria in columns A and B be met. The statement below is acting as an OR function currently.
= (A:A="Y")+(B:B="Y")
E.g.if I have two columns as follows I'd like a third column C with the formula to return as follows:
A B C
Y N {False,False,True}
N Y {False,False,True}
Y Y {False,False,True}
The formula above currently returns:
A B C
Y N {True,True,True}
N Y {True,True,True}
Y Y {True,True,True}
Use the TRANSPOSE() function: =TRANSPOSE(((A:A="Y")+(B:B="Y"))=2)
The CSE formula =(A:A="Y")+(B:B="Y") will return a tall array: {FALSE;FALSE;TRUE}. {FALSE,FALSE,TRUE} is a long array. TRANSPOSE will convert tall to long and vice-versa.

Count number of X in Column A when Y is in either Column B or C

Simplified data in columns A, B and C:
A | B | C
X | | Y
| Y |
X | Y |
Z | | Y
X | |
How to count the number of X when the value of Y is present in column B or C?
(ie. result is 2). Was thinking about COUNTIFS but can't seem to get the formula right :(
You can't do this with a single COUNTIFS, because conditions in COUNTIFS are AND, not OR. You can do it with multiple COUNTIFS, or an Array Formula (not recommended - that's a bit overkill for this case)
You need to count up all the rows where Column A is X and Column B is Y, add all the rows where Column A is X and Column C is Y, and then decide of a row where Column A is X and both Column B and Column C are Y is possible and/or should be counted twice.
If it is possible, but should not be double-counted, then you will need to subtract all the rows where Column A is X and Columns B and C are both Y.
=COUNTIFS($A:$A,"X",$B:$B,"Y") + COUNTIFS($A:$A,"X",$C:$C,"Y") - COUNTIFS($A:$A,"X",$B:$B,"Y"",$C:$C,"Y")
If it can't be in both, or you want that to count as 2 rows instead of 1, then you don't need the third COUNTIFS
As an Array Formula (using SUMPRODUCT instead of SUM, because then we don't need to use Ctrl+Shift+Enter), for reference:
=SUMPRODUCT(--($A:$A="X")*--(--($B:$B="Y")+($C:$C="Y")>0))
(The >0 is so that the OR (+) doesn't double-count)
Because you never have a double-Y case, you can use:
=SUMPRODUCT((A1:A5="X")*(B1:B5="Y"))+SUMPRODUCT((A1:A5="X")*(C1:C5="Y"))

EXCEL counting empty rows

A B C D E F G H
1 Y Y Y X
2 X X
3 Y Y
4 X X
5 Y Y Y X
Count the number of empty rows (from Columns A to E) and put result here. Answer should be 2 from example above.
Hi Folks,
I'm struggling to find the correct Excel formula to count the number of rows with no data from columns A through E, and putting that answer in a cell. These 'empty rows' may have data in later columns (like F, G, H), but I just want to count the rows with no data from columns A to E.
Any help would be appreciated.
Since array formulas tend to confuse people, here's a non-Array formula approach:
Place =IF(COUNTA(A1:E1)=0,1,0) into row 1 of (for example) column I and drag down to row 5. Then place a sum formula below that to get the answer, for example: =SUM(I1:I5)
Try this array formula,
=SUM(IF(ROW(1:5), IF(A1:A5&B1:B5&C1:C5&D1:D5&E1:E5="", 1)))
Remember to finalize with ctrl+shift+enter, not just enter.
You could also use a variation on the standard formula for getting row sums of a 2d array
=SUM(N(MMULT(N(A1:E5=""),TRANSPOSE(COLUMN(A1:E5)^0))=COLUMNS(A1:E5)))
or
=SUM(N(MMULT(N(A1:E5="Y"),TRANSPOSE(COLUMN(A1:E5)^0))=0))
Again they are array formulas and have to be entered with CtrlShiftEnter

Return value of last populated cell in variable range

Into column D, I'd like to copy the value from the last cell with data in columns E up until the column with the header "DETAIL". There might be anywhere from 2 to 15 columns from E until the column with that header, so that's where I'm stuck. So to be clear, an example:
A B C D E F G H DETAIL
1 x x x a b c d x
2 x x x x
3 x x x c b a x
3 x x x d c x
Should fill column D like so:
A B C D E F G H DETAIL
1 x x x d a b c d x
2 x x x x
3 x x x a c b a x
3 x x x c d c x
I don't mind handling this with a formula (which I couldn't come up with) or programmatically.
Create a dynamic named range by pressing CtrlF3 to bring up the Name Manager, click New, name the range something (I chose MyRange) and then use this formula to define it (Note you may need to change the Sheet name):
=Sheet1!E2:INDEX(Sheet1!2:2,MATCH("Detail",Sheet1!$1:$1,0)-1)
Then, in cell D2 and copied down, use this formula (I did not use IFERROR so that it would be backwards compatible):
=IF(COUNTA(MyRange),INDEX(MyRange,MATCH(REPT("z",255),MyRange)),"")
Here are the results (highlighted) using your provided sample data:
Please try:
=IFERROR(INDEX(F2:T2,,MATCH("zzzzzz",F2:T2)),"")
in D2 and copied down to suit.
Try using LOOKUP:
=IFERROR(LOOKUP(9^99,SEARCH("*",E1:H1),E1:H1),"")
SEARCH("*",E1:H1) returns a number when it matches any character and an error when the cell is blank. LOOKUP then returns the contents of the cells of the last number smaller than 9^99 in the array generated by SEARCH.
For example, in the first row, SEARCH("*",E1:H1) returns {1,1,1,1} so that LOOKUP returns the last 1, being d.
In the third row, SEARCH("*",E3:H3) returns {1, 1, 1, #VALUE!} and LOOKUP returns the last 1, which is a here.
This formula will work with numbers and text alike. The downside is that it is considered slower than INDEX/MATCH. On the other hand, you can modify the INDEX/MATCH to work with numbers, or modify it to work for both but becomes an array formula:
=IFERROR(INDEX(E1:H1,,MATCH(1,SEARCH("*",E1:H1))),"")
[Works with Ctrl+Shift+Enter, otherwise returns an empty cell with Enter alone]

Resources