Count a value in a cell (within a specified range) every nth cell along the row

nature98

New Member
Joined
Feb 3, 2024
Messages
12
Office Version
  1. 365
Platform
  1. Windows
I am stumped. I tried researching the forums and google to get a formula that work. I am trying to count a value in a cell (with a range of 3 or higher) every 4th cell along the row. I do not want the formula to count text or blank cells. My cell range across the row is G28:HK28. The cell I want to count starts at G28. Hope you gurus can help. I know how to use the CountIF functions but when I tried the sumproduct and mod functions, I just cannot get it to add up correctly.

Help me Okbi Wan Kenobi...you are my only hope.
 
I think the earlier solution could be simplified...the a>=3 condition automatically means the value must be a number, so the ISNUMBER part isn't needed. Here's a revision to accommodate "X":
MrExcel_20240203.xlsx
FGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAO
2834214526719467454568221156aX-9
29count7
Sheet2
Cell Formulas
RangeFormula
G29G29=LET(a,FILTER(G28:HK28,MOD(SEQUENCE(,COLUMNS(G28:HK28),0),3)=0),SUM(--(((a="X")+(a>=3))>0)))
Cells with Conditional Formatting
CellConditionCell FormatStop If True
G28:HK28Expression=MOD(COLUMNS($G$28:G$28)-1,3)=0textNO

The formula works. Thank you soooooo much! Really appreciate your help with the excel formula.
 
Upvote 0

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
You're welcome...glad to help, and welcome to the MrExcel board.
 
Upvote 0
You're welcome...glad to help, and welcome to the MrExcel board.
One last question for you KRice. The same question above applies and your table still apllies...but this time, what is the formula to SUM the values every 4th cell along the row.
 
Upvote 0
Do you want to ignore any "X" values, or assign them some value?

The easiest option is to adapt the earlier formula and swap out SUM for SUMPRODUCT and incorporate the "a" array (the filtered array containing array positions 1, 4, 7, etc.), but ignoring the "X"...it would look like this:
MrExcel_20240203.xlsx
FG
30sum25
Sheet2
Cell Formulas
RangeFormula
G30G30=LET(a,FILTER(G28:HK28,MOD(SEQUENCE(,COLUMNS(G28:HK28),0),3)=0),SUMPRODUCT(a,ISNUMBER(a)*(a>=3)))
 
Last edited:
Upvote 0
Do you want to ignore any "X" values, or assign them some value?

The easiest option is to adapt the earlier formula and swap out SUM for SUMPRODUCT and incorporate the "a" array (the filtered array containing array positions 1, 4, 7, etc.), but ignoring the "X"...it would look like this:
MrExcel_20240203.xlsx
FG
30sum25
Sheet2
Cell Formulas
RangeFormula
G30G30=LET(a,FILTER(G28:HK28,MOD(SEQUENCE(,COLUMNS(G28:HK28),0),3)=0),SUMPRODUCT(a,ISNUMBER(a)*(a>=3)))
X would be ignored. But if I nneed to count X...include that fornula as well.
 
Upvote 0
Okay...so the counting formula uses SUM in post #10, and the summing formula uses SUMPRODUCT in post #14 (and it just ignores "X" values").
 
Upvote 0
Okay...so the counting formula uses SUM in post #10, and the summing formula uses SUMPRODUCT in post #14 (and it just ignores "X" values").
Got it. Another question popped up LOL! How do I calculate the COUNT of only "X"?

=LET(a,FILTER(G28:HK28,MOD(SEQUENCE(,COLUMNS(G28:HK28),0),3)=0),SUM(--(((a="X")+(a>=3))>0)))

Remove the text in red?
 
Upvote 0
Almost. The addition is used to establish an OR condition...any value in the "a" array may be either =X or >=3 or (not in this case), both. This leads to four combinations of TRUE's and FALSE's, and when those are added, TRUE is coerced to 1, and FALSE to 0. So the four combinations are 0+0=0, 1+0=1, 0+1=1, 1+1=2, and the >0 condition is used to accept any items satisfying at least one condition. But if you want to count only the X's, then we can simply evaluate the "a" array for X's, coerce those TRUE's and FALSE's to 1's and 0's using the double unary operator (--), and sum, as shown below (note that both "x" and "X" are accepted here):
MrExcel_20240203.xlsx
FGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQ
2834214526719467454568221156aX-9x
29count7
30sum25
31count X2
Sheet2
Cell Formulas
RangeFormula
G29G29=LET(a,FILTER(G28:HK28,MOD(SEQUENCE(,COLUMNS(G28:HK28),0),3)=0),SUM(--(((a="X")+ISNUMBER(a)*(a>=3))>0)))
G30G30=LET(a,FILTER(G28:HK28,MOD(SEQUENCE(,COLUMNS(G28:HK28),0),3)=0),SUMPRODUCT(a,ISNUMBER(a)*(a>=3)))
G31G31=LET(a,FILTER(G28:HK28,MOD(SEQUENCE(,COLUMNS(G28:HK28),0),3)=0),SUM(--(a="X")))
Cells with Conditional Formatting
CellConditionCell FormatStop If True
G28:HK28Expression=MOD(COLUMNS($G$28:G$28)-1,3)=0textNO
 
Upvote 0

Forum statistics

Threads
1,215,087
Messages
6,123,050
Members
449,092
Latest member
ikke

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