Excel formula to Sum 12 rows every 3 rows - excel

I need to make a sum of 12 rows every 3 rows in excel. That is, I need to sum first from C4 to C15, then from C7 to C18, and so on.

You can use OFFSET function for this, also volatile, but shorter!
Assuming first formula in E2 copied down
=SUM(OFFSET(C$4,(ROWS(E$2:E2)-1)*3,0,12))
I prefer this because it explicitly contains all the required information
C4 = first cell to sum,
E2 = first cell with formula,
3 = row increment,
12 = number of cells to sum
The above gives you the sums on successive rows from E2 (or any other chosen cell) down. If you actually want the sum to be shown every 3 cells e.g. on the first row for each sum then that's simpler - try this formula in D4 copied down
=IF(MOD(ROWS(E$2:E2),3)=1,SUM(C4:C15),"")
.......or even easier.....just put this formula in D4
=SUM(C4:C15)
....leave D5 and D6 blank, then select the range D4:D6 and drag down

You can also use the non-volatile INDEX function
=SUM(INDEX(C:C,ROWS($1:1)*3+1):INDEX(C:C,ROWS($1:1)*3+12))
This works because INDEX returns a reference so you can use the normal Ref1:Ref2 notation for a range.

=SUM(INDIRECT("C"&ROW(1:1)*3+1&":C"&ROW(1:1)*3+12))
Be warned that INDIRECT() is a volatile formula... This means that any change made anywhere in the workbook this formula will recalculate and can cause performance issues.

Related

How to reference an entire column from one cell in a spreadsheet function

I am looking for a way to accomplish the following using spreadsheet formulae: the output in cell D5 should be the array from cell B5 to the last populated cell (assume the range is contiguous). Thus if text were typed into cell B10, the output would automatically expand.
However, I want to avoid the volatile OFFSET and INDIRECT functions.
So I have this formula in cell D5:
=UPPER(B5:INDEX(B:B,ROW(B5)+COUNTA(B5:INDEX(B:B,ROWS(B:B),,1))-1))
but this is unsatisfactory as it references the B:B column.
In effect I want a construction that returns me B:B given the cell B5 ie the equivalent of =INDIRECT("C" & COLUMN(B5),"FALSE"), but in a non-volatile format.
Any suggestions?
NB. I don't have the very latest Excel. I have LET, SEQUENCE, FILTER etc, but not LAMBDA and the functions that came with it (ie I can't do recursive LAMBDA calls).
Make column B data into a table
the content of cell D5 can then be dragged to a different location, without the formula results changing.

Sum divided series

I wanna ask you. I have value which I want divide and sum. I will give you example:
Which I want series sum
A1 Value 5 B1
A3 Count 4 B3
10,41666667 **B5**
=SUM(B1;B1/2;B1/3;B1/4)
I want when I change count value formula will calculate automaticaly as formula "=SUM(B1;B1/2;B1/3;B1/4)"
Count value continues up to n, formula should work even if count value 1000.
Please help. I hope so I could explain.
Try this formula
Formula used in cell B5
=SUM(B1/ROW(INDIRECT("1:"&$B$3)))
Or you can use SUMPRODUCT Function as well, to avoid the CTRL+SHIFT+ENTER
Formula used in cell D5
=SUMPRODUCT(D1/ROW(INDIRECT("1:"&$D$3)))

Creating a column formula in excel, changing only one variable

I have a very basic excel file for looking at the cost of shares and calculating a profit/loss %.
I have the initial purchase price in cell E3 and I have the current share price in F3. I have calculated the percentage profit/loss in G3 by the following formula
=(F3/E3)*100 - 100
What I now want is to be able to apply this formula to the whole G column as I enter a new share price into the F column, it will use E3 as a constant in the formula to calculate daily profit/loss. So the new formula I want is effectively;
=(Fi/E3)*100 - 100
Where Fi = F3, F4, F5, F6 and so on...
I have tried dragging the cell down to extend the formula, which works to an extent but it does not keep E3 constant so I get a divide by zero error.
Any suggestions? Thanks
Start with =(F3/E$3)*100 - 100. The $ is an absolute anchor that tells the formula not to change the 3 in E$3 when filled down.
If there is no value in column F, you can have the result returned as a zero-length string (e.g. "") which will make the cell in column G that holds the formula look blank.
=IF(LEN(F3), (F3/E$3)*100 - 100, "")
Use an absolute reference for E3 in the formula:
$e$3
This will lock the reference if you drag the cell down.
The other way around, if you want to lock the character:
=(F3/$E3)*100 - 100

Excel - Drag and repeat formula pattern series

I am trying to replicate a pattern of formulas in excel but it's not appearing the way I expect but I'm looking for a solution.
I have the first 2 rows in a table defined and it has 4 columns
The formulas are as follows:
A1 =CONCATENATE(Scores!D11," (",Scores!F11,")")
B1 =Scores!AF11
C1 =Scores!AH11
D1 =Scores!AH15
A2 =CONCATENATE(Scores!D17," (",Scores!F17,")")
B2 =Scores!AF17
C2 =Scores!AH17
D2 =Scores!AH21
I expected when I highlight the cells and dragged down that it would repeat the formula by adding 6 to all the value as shown above.
Is there an easy way to autofill the rows I need as I have to populate over 80 and possible more in the future.
If you use instead in A1:
=CONCATENATE(INDEX(Scores!D:D,11+6*(ROWS($1:1)-1))," (",INDEX(Scores!F:F,11+6*(ROWS($1:1)-1)),")")
then copy down as required, which has the additional benefit of avoiding volatile INDIRECT set-ups.
Regards
You could use Indirect() for the formulas to determine which row they are supposed to go after. Basing the logic off of the current row on which the formula resides:
In A1:
=Concatenate(Indirect("Scores!D" & (11 + (Row()-1)*6)), " (", Indirect("Scores!F" & (11 + (Row()-1)*6)), ")")
In B1:
=Indirect("Scores!AF" & (11 + (Row()-1)*6))
You can see what's happening more clearly in that B1 example. We are dynamically determining the number 11 by using that formula 11 + (Row()-1)*6. For B1 the ROW() returns 0, so the formula is 11+(0-1)*6 or 11. That 11 is concatenated with Scores!AF and then Indirect() returns that back to the formula so it can then look up Scores!AF11 from the workbook and return it's value.
When you copy that formula down to B2 the ROW() returns 2 and the formula then works out to 17, which is your B1 value + 6.
That's a few hops, skips, and jumps to get what you need, but the formula will copy down nicely and save you a lot of typing.

Excel - Find the biggest gap in a set of numbers?

I have a series of numbers
0,1,99,5,5,98,9
They are unsorted and will remain that way.
I cannot use macros.
I want the answer 89 from a formula or an array formula.
89 is the biggest gap (between 9 and 98) in this series when sorted.
I want a formula, no vba, and no sorting my column or row.
I need a formula that sorts the list and subtracts one cell relative to the sorted list and gives the largest difference of the list of differences it creates.
so the list becomes 0,1,5,5,9,98,99
subtracts the current from the previous (na,1,4,0,4,89,1)
and gives me the max 89.
My list is a column of 7 rows.
This formula must be array-entered. In the formula RNG refers to the range where you have entered your numbers, e.g. A1:A7
=MAX(LARGE(RNG,ROW(INDIRECT("1:"&-1+COUNT(RNG))))-
LARGE(RNG,ROW(INDIRECT("2:"&COUNT(RNG)))))
To array-enter a formula, after entering
the formula into the cell or formula bar, hold down
ctrl-shift while hitting enter. If you did this
correctly, Excel will place braces {...} around the formula.
You can see how the formula works by using the Evaluate Formula option on the Formula Auditing tab of the Formulas ribbon.
In brief, the formula works by creating two arrays, sorted in order of size. The "K" value of the LARGE function is an array created by the ROW(INDIRECT sequence. The first returns
{1;2;3;4;5;6}
and the second returns
{2;3;4;5;6;7}
The two arrays of values returned would then be:
{99;98;9;5;5;1}
{98;9;5;5;1;0}
Subtracting one from the other results an array of the differences, and we find the MAX.
MAX(A:A) - LARGE(A:A,2) gives the difference between the largest and second-largest value if your numbers are in column A. Don't put this formula in column A.
Place the values in A1 thru A7 in any order!
In B1 enter:
=RANK(A1,$A$1:$A$7,0)+COUNTIF($A$1:$A1,A1)-1
and copy down thru B7
In C1 enter:
=INDEX($A$1:$A$7,MATCH(ROW(),B$1:B$7,0))
and copy down thru C7
In D2 enter:
=C1-C2
and copy down thru C7
Finally in E1 enter:
=MAX(C:C)
Column B represents the order of the values in column A if they were sorted. Column C contains the values of column A in sorted order. Column D are the differences and E1 gives the desired answer. Here is an example:

Resources