Can someone explain on how this strange excel formula works exactly?

jvs411

New Member
Joined
Sep 18, 2023
Messages
27
Office Version
  1. 365
Platform
  1. Windows
So I wanted to find out how to sum up a range of numbers where only every subsequent number that is three columns apart will taken in to be calculated.
For example if I have the range of (2 , 3 , 5 , 1 , 2 , 4 , 3), the formula would only calculate 2+1+3 and return 6.

I asked an AI for help and it gave me this formula:

1701311986060.png


The formula DOES work in giving me 6 as shown but I'm curious as to how this formula works exactly?
From what I see, if the IF() statement is made true, wouldn't it only produce F9:L9?
And this means the formula will be SUMPRODUCT(F9:L9), which obviously won't give a result of 6, as seen below:
1701312106140.png


So how come the full formula in the first image works in giving the answer 6?? How does the formula work exactly?
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Here is a step by step of the formula. I hope it works out.
SUMPRODUCT is essentially matrix arithmetic (also shown below the SUMPRODUCT line):

Mr Excel Questions 73.xlsm
EFGHIJKL
92351243
196
20Column F9:L96789101112
21COLUMN(F9)6666666
22Difference0123456
23Modulo 3 of Difference0120120
24if equal to zeroTRUEFALSEFALSETRUEFALSEFALSETRUE
25(value of TRUE or FALSE(unary operation))1001001
26Values in the range2351243
27SUMPRODUCT6
28Addl info: Matrix Mult2001003
29SUM of Matrix Mult6
Sheet6
Cell Formulas
RangeFormula
F21:L21G21=COLUMN($F$9)
F22:L22G22=G20-G21
F19F19=SUMPRODUCT(IF(MOD(COLUMN(F9:L9)-COLUMN(F9),3)=0,F9:L9,0))
F20:L20F20=COLUMN(F9:L9)
F23:L23F23=MOD(F22:L22,3)
F24:L24F24=F23#=0
F25:L25F25=--(F24:L24)
F26:L26F26=F9:L9
F27F27=SUMPRODUCT(F25#,F26#)
F28:L28F28=F25#*F26#
F29F29=SUM(F28#)
Dynamic array formulas.
 
Upvote 0
Solution
So I wanted to find out how to sum up a range of numbers where only every subsequent number that is three columns apart will taken in to be calculated.
I know your question in this thread is about the specific SUMPRODUCT formula, and I don't what your particular circumstances are but when trying to calculate from evenly spaced columns like that it is common for the headings in those columns to be the same or have something in common and those headings can be used to make the calculation easier. A couple of examples are shown below.

23 11 30.xlsm
FGHIJKLMNOP
1BudgetActualTotalBudgetActualTotalBudgetActualTotalTotal Budget
22351233586
3641044871917
4
5
6Budget JanActual JanTotal JanBudget FebActual FebTotal FebBudget MarActual MarTotal MarTotal Budget
72351233586
8641044871917
Sample
Cell Formulas
RangeFormula
P2:P3P2=SUMIF(F$1:N$1,"Budget",F2:N2)
P7:P8P7=SUMIF(F$6:N$6,"Budget*",F7:N7)


Also, since you have Excel 365, here is another alternative if headings are not available or no use.

23 11 30.xlsm
FGHIJKL
92351233
10
116
Sample (2)
Cell Formulas
RangeFormula
F11F11=SUM(INDEX(F9:L9,SEQUENCE(,ROUNDUP(COLUMNS(F9:L9)/3,0),,3)))
 
Last edited:
Upvote 0
Here is a step by step of the formula. I hope it works out.
SUMPRODUCT is essentially matrix arithmetic (also shown below the SUMPRODUCT line):

Mr Excel Questions 73.xlsm
EFGHIJKL
92351243
196
20Column F9:L96789101112
21COLUMN(F9)6666666
22Difference0123456
23Modulo 3 of Difference0120120
24if equal to zeroTRUEFALSEFALSETRUEFALSEFALSETRUE
25(value of TRUE or FALSE(unary operation))1001001
26Values in the range2351243
27SUMPRODUCT6
28Addl info: Matrix Mult2001003
29SUM of Matrix Mult6
Sheet6
Cell Formulas
RangeFormula
F21:L21G21=COLUMN($F$9)
F22:L22G22=G20-G21
F19F19=SUMPRODUCT(IF(MOD(COLUMN(F9:L9)-COLUMN(F9),3)=0,F9:L9,0))
F20:L20F20=COLUMN(F9:L9)
F23:L23F23=MOD(F22:L22,3)
F24:L24F24=F23#=0
F25:L25F25=--(F24:L24)
F26:L26F26=F9:L9
F27F27=SUMPRODUCT(F25#,F26#)
F28:L28F28=F25#*F26#
F29F29=SUM(F28#)
Dynamic array formulas.

Thanks! That explains it perfectly
 
Upvote 0

Forum statistics

Threads
1,223,884
Messages
6,175,175
Members
452,615
Latest member
bogeys2birdies

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