Do NOT count cell if adjacent cells have a 1

abrig005

Board Regular
Joined
Jan 6, 2017
Messages
82
Office Version
  1. 365
Platform
  1. Windows
Hello,
Each cell is either blank or has a 1.
I want to count the number of 1's only if there is not a 1 in any adjacent cell.
For example building 1 would only be counted under Class 2 and not 4 6 and 7
building 13 would only be counted under Class 1 and not Class 6 and 7
Class 1 is a simple count....
Class 2 would only count if there is not a 1 in the adjacent cell in Class 1 etc.

Thank you!!!!!!!!!!!!!!!
 

Attachments

  • Capture.JPG
    Capture.JPG
    81.5 KB · Views: 11

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Hi,

Is this what you mean:

Book3.xlsx
ABCDEFGH
112467Count
21111135
32111
4311
5411
6511
7611
8711
9811
10911
111011
121111
131211
1413111
151411
161511
1716111
181711
191811
20191
21201
22211
23221
24231
25241
26251
27261
28271
29281
30291
31301
32311
33321
34331
Sheet938
Cell Formulas
RangeFormula
H2H2=COUNT(B2:B34)+COUNTIFS(C2:F34,"1",B2:E34,"")
 
Upvote 0
What version of Excel are you using?

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

Maybe
+Fluff 1.xlsm
ABCDEFGH
112467Count
21111133
32111
4311
5411
6511
7611
8711
9811
10911
111011
121111
131211
1413111
151411
161511
1716111
181711
191811
20191
21201
22211
23221
24231
25241
26251
27261
28271
29281
30291
31301
32311
33321
34331
Lists
Cell Formulas
RangeFormula
H2H2=SUM(--(MMULT(--(B2:F34=1),{1;1;1;1;1})>0))
 
Upvote 0
Sorry for not being clear. I need to count all the 1's in Class 2 only if there isn't a 1 in Class 1, then Count all Class 4 only if there isn't a 1 in Class 2 or Class 1, then Count all Class 6 only if there isn't a 1 in Class 4 or Class 2 or Class 1, then Count all the 1's in Class 7 only if there isnt a 1 in Class 6 or Class 4 or Class 2 or Class 1
 
Upvote 0
So what you're saying is you want to count the total number of rows that have a 1 somewhere in them?
If so try the formula in post#3
 
Upvote 0
The results for the example above should be (note i have thousands of rows the example is just a subset)

Class 1 = 2
Class 2 = 1
Class 4 = 1
Class 6 = 14
Class 7 = 15
 
Upvote 0
What version of Excel are you using?

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
That is the build not the Version of Excel which will be something like 2019, 2021, 365
 
Upvote 0

Forum statistics

Threads
1,215,346
Messages
6,124,417
Members
449,157
Latest member
mytux

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