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

[TABLE="width: 99"]
<tbody>[TR]
[TD]column N[/TD]
[/TR]
[TR]
[TD]Los Angeles[/TD]
[/TR]
[TR]
[TD]Los Angeles[/TD]
[/TR]
[TR]
[TD]Los Angeles[/TD]
[/TR]
[TR]
[TD]Los Angeles[/TD]
[/TR]
[TR]
[TD]Los Angeles[/TD]
[/TR]
[TR]
[TD]Los Angeles

[/TD]
[/TR]
</tbody>[/TABLE]

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

[TABLE="width: 99"]
<tbody>[TR]
[TD]column N[/TD]
[/TR]
[TR]
[TD]Los Angeles[/TD]
[/TR]
[TR]
[TD]Los Angeles[/TD]
[/TR]
[TR]
[TD]Los Angeles[/TD]
[/TR]
[TR]
[TD]Barcelona[/TD]
[/TR]
[TR]
[TD]Barcelona[/TD]
[/TR]
[TR]
[TD]Rome[/TD]
[/TR]
</tbody>[/TABLE]

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

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
=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
[TABLE="class: grid"]
<tbody>[TR]
[TD][/TD]
[TD]
A
[/TD]
[TD]
B
[/TD]
[/TR]
[TR]
[TD]
1
[/TD]
[TD]Los Angeles[/TD]
[TD]yes[/TD]
[/TR]
[TR]
[TD]
2
[/TD]
[TD]Los Angeles[/TD]
[TD]yes[/TD]
[/TR]
[TR]
[TD]
3
[/TD]
[TD]Los Angeles[/TD]
[TD]yes[/TD]
[/TR]
[TR]
[TD]
4
[/TD]
[TD]Los Angeles[/TD]
[TD]yes[/TD]
[/TR]
[TR]
[TD]
5
[/TD]
[TD]Los Angeles[/TD]
[TD]yes[/TD]
[/TR]
[TR]
[TD]
6
[/TD]
[TD]Los Angeles[/TD]
[TD]yes[/TD]
[/TR]
[TR]
[TD]
7
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
8
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
9
[/TD]
[TD]Los Angeles[/TD]
[TD]no[/TD]
[/TR]
[TR]
[TD]
10
[/TD]
[TD]Los Angeles[/TD]
[TD]no[/TD]
[/TR]
[TR]
[TD]
11
[/TD]
[TD]Dallas[/TD]
[TD]no[/TD]
[/TR]
[TR]
[TD]
12
[/TD]
[TD]Los Angeles[/TD]
[TD]no[/TD]
[/TR]
[TR]
[TD]
13
[/TD]
[TD]Los Angeles[/TD]
[TD]no[/TD]
[/TR]
[TR]
[TD]
14
[/TD]
[TD]Los Angeles[/TD]
[TD]no[/TD]
[/TR]
</tbody>[/TABLE]


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

<colgroup><col style="width: 25pxpx"><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]
[TD="bgcolor: #FAFAFA"]Los Angeles[/TD]
[TD="bgcolor: #FAFAFA"]Yes[/TD]

[TD="align: center"]2[/TD]
[TD="bgcolor: #FAFAFA"]Los Angeles[/TD]
[TD="bgcolor: #FAFAFA"]Yes[/TD]

[TD="align: center"]3[/TD]
[TD="bgcolor: #FAFAFA"]Los Angeles[/TD]
[TD="bgcolor: #FAFAFA"]Yes[/TD]

[TD="align: center"]4[/TD]
[TD="bgcolor: #FAFAFA"]Los Angeles[/TD]
[TD="bgcolor: #FAFAFA"]Yes[/TD]

[TD="align: center"]5[/TD]
[TD="bgcolor: #FAFAFA"]Los Angeles[/TD]
[TD="bgcolor: #FAFAFA"]Yes[/TD]

[TD="align: center"]6[/TD]
[TD="bgcolor: #FAFAFA"]Los Angeles[/TD]
[TD="bgcolor: #FAFAFA"]Yes[/TD]

[TD="align: center"]7[/TD]
[TD="bgcolor: #FAFAFA"]Los Angeles[/TD]
[TD="bgcolor: #FAFAFA"]No[/TD]

[TD="align: center"]8[/TD]
[TD="bgcolor: #FAFAFA"]Los Angeles[/TD]
[TD="bgcolor: #FAFAFA"]No[/TD]

[TD="align: center"]9[/TD]
[TD="bgcolor: #FAFAFA"]Dallas[/TD]
[TD="bgcolor: #FAFAFA"]No[/TD]

[TD="align: center"]10[/TD]
[TD="bgcolor: #FAFAFA"]Los Angeles[/TD]
[TD="bgcolor: #FAFAFA"]No[/TD]

[TD="align: center"]11[/TD]
[TD="bgcolor: #FAFAFA"]Los Angeles[/TD]
[TD="bgcolor: #FAFAFA"]No[/TD]

[TD="align: center"]12[/TD]
[TD="bgcolor: #FAFAFA"]Los Angeles[/TD]
[TD="bgcolor: #FAFAFA"]No[/TD]

[TD="align: center"]13[/TD]
[TD="bgcolor: #FAFAFA"]San Jose[/TD]
[TD="bgcolor: #FAFAFA"]No[/TD]

[TD="align: center"]14[/TD]
[TD="bgcolor: #FAFAFA"]San Jose[/TD]
[TD="bgcolor: #FAFAFA"]No[/TD]

[TD="align: center"]15[/TD]
[TD="bgcolor: #FAFAFA"]San Jose[/TD]
[TD="bgcolor: #FAFAFA"]No[/TD]

[TD="align: center"]16[/TD]
[TD="bgcolor: #FAFAFA"]Oakland[/TD]
[TD="bgcolor: #FAFAFA"]No[/TD]

[TD="align: center"]17[/TD]
[TD="bgcolor: #FAFAFA"]San Jose[/TD]
[TD="bgcolor: #FAFAFA"]No[/TD]

[TD="align: center"]18[/TD]
[TD="bgcolor: #FAFAFA"]San Jose[/TD]
[TD="bgcolor: #FAFAFA"]No[/TD]

</tbody>
Sheet4

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH="width: 10px"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]B1[/TH]
[TD="align: left"]=IF(COUNTIF(OFFSET($A$1,FLOOR(ROW()-1,6),0,6,1),A1)=6,"Yes","No")[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
 
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,224,824
Messages
6,181,187
Members
453,020
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