Here's how this works...
=SUM(OFFSET($A1,,(COLUMNS($A4:A4)-1)*3,,3))
You want to sum groups of 3 cells starting from cell A1.
We use the OFFSET function to pass the range of these 3 cells to the SUM
function.
These are the arguments that OFFSET takes:
OFFSET(reference,rows,cols,height,width)
$A1 is the reference or "anchor" cell. That's where we're starting from.
Since the data we're interested in is all on the same row we don't need to
offset A1 by any rows so that argument is empty and defaults to 0. That
means offset A1 by 0 rows.
We're interested in cells in groups of 3 so we need to offset A1 by 3
columns with each cell that we copy the formula to. That's what the cols
argument (COLUMNS($A4:A4)-1)*3 is doing.
The groups of cells we're interested in are A1:C1, D1:F1, G1:I1, J1:L1, etc.
So, we use (COLUMNS($A4:A4)-1)*3 to increment the column offset by 3 for
each cell that the formula is copied to.
With the formula entered in the first cell of A4, COLUMNS($A4:A4) evaluates
to 1. The columns function simply counts the number of columns referenced in
its argument. As we copy the formula across the range reference will
incremnt like this:
COLUMNS($A4:A4) = 1
COLUMNS($A4:B4) = 2
COLUMNS($A4:C4) = 3
COLUMNS($A4
4) = 4
We use the multiplier of 3 to increment the offset by groups of 3.
So COLUMNS($A4:A4)*3 = 3 which means offset A1 by 3 columns and that would
put us at cell D1. However, we want to start at cell A1 not cell D1 so we
use -1 to adjust for this. Like this:
(COLUMNS($A4:A4)-1) = 0 * 3 = 0
(COLUMNS($A4:B4)-1) = 1 * 3 = 3
(COLUMNS($A4:C4)-1) = 2 * 3 = 6
(COLUMNS($A4
4)-1) = 3 * 3 = 9
So, this means offset A1 by 0 columns, 3 columns, 6 columns, 9 columns, etc.
Now, we need to tell OFFSET how high and wide the range we're interested in
is. Since the data is on the same row we leave the height argument empty and
this defaults to 1. We want to sum every 3 cells so the width argument is 3.
So, in plain English:
A4 = offset A1 by 0 columns and sum A1:C1
B4 = offset A1 by 3 columns and sum D1:F1
C4 = offset A1 by 6 columns and sum G1:I1
D4 = offset A1 by 9 columns and sum J1:L1