Calculate the number of non blank cells every nth row in a column

ozbeachbum

Board Regular
Joined
Jun 3, 2015
Messages
159
Office Version
  1. 2021
Platform
  1. Windows
Hi All,
I am trying to calculate the number of non blank cells every nth (6th) row in a column, cells are formatted as number.
EG: Cell B2=18; B8=0, B14=33 Answer Required 2. Two non blank cells.
Any assistance would be greatly appreciated.
Dave.
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Thanks again Jeff you have been so helpful.
I feel I am putting you to a lot of trouble.
As I said my ability to build formulas is not that great and I am trying to understand how to adjust the formula if I require it in another position as the =# changes dependent on position.
Can you provide me with an explanation of how you ascertain the =#.
Thank you again for your assistance and input.
Dave.
 
Upvote 0
To determine the equalnumber put the following formula in any cell:

Rich (BB code):
=MOD(firstrow, skipsize)

where

firstrow is the number of the first row of data
skipsize is the number of rows to skip each time, 6 in your case

and the result will be your equalnumber.

Then your formula will be


Rich (BB code):
=SUMPRODUCT(--(MOD(ROW(firstrow:lastrow),skipsize)=equalnumber)*--((Bfirstrow:Blastrow)<>0))

I hope that covers it
 
Upvote 0
You are going to think me totally stupid.
The information you provided is well laid out and shows what the positions represent.
What I need to know is how you arrive at the =equalnumber.

The formula you first provided was =2
=SUMPRODUCT(--(MOD(ROW(2:150),6)=2)*--((B2:B150)<>0))

When I changed position it became =4
=SUMPRODUCT(--(MOD(ROW(70:322),6)=4)*--((P70:P322)<>0))

Should I need to use the formula in another position say
=SUMPRODUCT(--(MOD(ROW(20:322),6)=?)*--((P70:P322)<>0))

How do I work out what the =equalnumber should be.
I am looking at it mathematically but can't see an answer.
Thank you so much for your time and effort.
 
Upvote 0
That's the first thing I described in post #6.

If your data starts on row 2, MOD(2,6) = 2 because 2 divided by 6 is 0 with a remainder of 2. So every 6th row is going to have a remainder of 2 when you divide by 6.

$scratch.xlsm
AB
1Row NumberRemainder when divding by 6
222
333
444
555
660
771
882
993
10104
11115
12120
13131
14142
15153
16164
17175
18180
19191
20202
21213
22224
Sheet13
Cell Formulas
RangeFormula
B2:B22B2=MOD(A2,6)
A3:A22A3=A2+1


If your data starts on row 70, you need to select rows that have that remainder. MOD(70,6) = 4, because 70 divided by 6 is 11 with remainder 4.

$scratch.xlsm
AB
1Row NumberRemainder when divding by 6
2704
3715
4720
5731
6742
7753
8764
9775
10780
11791
12802
13813
14824
15835
16840
17851
18862
19873
20884
21895
22900
Sheet13
Cell Formulas
RangeFormula
B2:B22B2=MOD(A2,6)
A3:A22A3=A2+1


If your data starts on row 20, you need to select rows that have that remainder. MOD(20,6) = 2, because 20 divided by 6 is 3 with remainder 2.

$scratch.xlsm
AB
1Row NumberRemainder when divding by 6
2202
3213
4224
5235
6240
7251
8262
9273
10284
11295
12300
13311
14322
15333
16344
17355
18360
19371
20382
21393
22404
Sheet13
Cell Formulas
RangeFormula
B2:B22B2=MOD(A2,6)
A3:A22A3=A2+1
 
Upvote 0
Thank you so much for your time and effort with a novice.
I did not know that the MOD(A70,6) was a division, however I did do that manually and as I got 11.66, I couldn't see how that was applicable.
I never thought to use that part of the formula to get the answer.
Now that you show it in such detail, I have finally got it and will leave you in peace.
Thanks once again, your are a champion.
Cheers,
Dave.
 
Upvote 0
Not MOD(A70,6), just MOD(70,6)

MOD is not itself a division, it gives you the remainder of integer division. 70/6 is 11.66 but you have to do integer division. 70/6 is 11 with remainder 4. The biggest divisor of 6 into 70 is 11. That gives 66. So you have 4 left over.

I don't mean to be condescending but this is grade-school arithmetic. Please see Division and Remainders for more of a description.
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,862
Members
449,052
Latest member
Fuddy_Duddy

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