if all values in a range are the same, return yes

prochasska

New Member
Joined
Jan 16, 2018
Messages
9
Hello,

I have a table in Excel where I want to have a formula which if all values every six cells in a column are equal, returns yes for the six cells and to return no if the values are not equal.
Here is an example.

The formula should return yes, all the cells in column N are the same

column N
Los Angeles
Los Angeles
Los Angeles
Los Angeles
Los Angeles
Los Angeles


<tbody>
</tbody>

The formula should return no, as not all values in the six cells are the same

column N
Los Angeles
Los Angeles
Los Angeles
Barcelona
Barcelona
Rome

<tbody>
</tbody>

I know that a countif function should be incorporated in an if function but I cannot get it right.
The formula returns yes only for the first of six cells if the condition is true and not for the six cells of the range.

I hope someone can help me create a formula which works in this case.
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
=IF(COUNTIF(N1:N6,N1)=6,"Yes","No")

There are 6 rows.
If the number of cells that match the first cell is 6 then all cells are the same so output Yes otherwise No.
 
Upvote 0
If it is always 6 cells then this should work
Excel 2010
ABC
1Los AngelesYes
2Los Angeles
3Los Angeles
4Los Angeles
5Los Angeles
6Los Angeles
7
8Los AngelesNo
9Los Angeles
10Dallas
11Los Angeles
12Los Angeles
13Los Angeles
Sheet1
Cell Formulas
RangeFormula
C1=IF(COUNTIF(A1:A6,A1)=6,"Yes","No")
C8=IF(COUNTIF(A8:A13,A8)=6,"Yes","No")
 
Upvote 0
Thank you. But thi sformula doesn't return "yes" for all the six cells but only for the forst one.
Do you have an idea how to make it return yes for all the six cells?
 
Upvote 0
This will do it

=IF(COUNTIF(N$1:N$6,N1)=6,"Yes","No")
and copy down for 6 rows.

Though I'm at a loss why you want the same result displayed 6 times.

UPDATE: Hang on, do you mean you want to check each group of 6 rows in the column?
ie rows 1-6 are the same rows 7-12 are the same rows 13-18 are the same etc 19-24, 25-30...
 
Last edited:
Upvote 0
Yes, I want to check each group of 6 rows (1-6, 7-12, etc.).
I want the result displayed because the value in rows 1-6 and 7-12 may be the same but the values in 13-18, 19-24 will not be.
Now imagine with a file of 4,000 and more rows ...
 
Upvote 0
A
B
1
Los Angelesyes
2
Los Angelesyes
3
Los Angelesyes
4
Los Angelesyes
5
Los Angelesyes
6
Los Angelesyes
7
8
9
Los Angelesno
10
Los Angelesno
11
Dallasno
12
Los Angelesno
13
Los Angelesno
14
Los Angelesno

<tbody>
</tbody>


b1=
IF(AND(A1=$A$1:$A$6),"yes","no") control+shift+enter copy down

b9=IF(AND(A9=$A$9:$A$14),"yes","no") control+shift+enter copy down
 
Upvote 0
This version automatically changes the range for every 6 rows, so you can enter it in B1 and drag down the column as far as needed.

AB
1Los AngelesYes
2Los AngelesYes
3Los AngelesYes
4Los AngelesYes
5Los AngelesYes
6Los AngelesYes
7Los AngelesNo
8Los AngelesNo
9DallasNo
10Los AngelesNo
11Los AngelesNo
12Los AngelesNo
13San JoseNo
14San JoseNo
15San JoseNo
16OaklandNo
17San JoseNo
18San JoseNo

<colgroup><col style="width: 25pxpx"><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet4

Worksheet Formulas
CellFormula
B1=IF(COUNTIF(OFFSET($A$1,FLOOR(ROW()-1,6),0,6,1),A1)=6,"Yes","No")

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>
 
Upvote 0
Here's another variation.
Funny how you think of a solution when you're on your way home!

=IF(A1="","",IF(SUMPRODUCT((QUOTIENT(ROW(A$1:A$12000)-1,6)=QUOTIENT(ROW()-1,6))*(A$1:A$12000<>"")*(A$1:A$12000=A1))=6,"Yes","No"))
and copy down
 
Upvote 0

Forum statistics

Threads
1,214,407
Messages
6,119,332
Members
448,888
Latest member
Arle8907

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