how can I sum every n cells in Excel? - excel

In Excel I need to just add up some cells across a row, like this:
=sum(A1+D1+G1+J1)
As you can see, it's just every third cell. I have to do this often so I'd love an equation I could copy and paste.
Is there a way to say "sum every third cell from A1 to V1"?

You can use an array formula
=SUM(IF(MOD(COLUMN(A1:V1),3)=1,A1:V1,0))
Confirm with Ctrl, Shift and Enter and curly brackets will surround the formula.
Btw, all this stuff is online.

Related

Change part of excel formula with a constant value

I have an excel formula across a column for which the base changes every "x" number of rows. Note this "x" is not constant and keeps changing. e.g.
=D1/SUM(D$1:D$4)
=D2/SUM(D$1:D$4)
=D3/SUM(D$1:D$4)
=D4/SUM(D$1:D$4)
=D5/SUM(D$5:D$9)
=D6/SUM(D$5:D$9)
=D7/SUM(D$5:D$9)
=D8/SUM(D$5:D$9)
=D9/SUM(D$5:D$9)
I am trying to change the first part of the formulas without changing the second and vice versa. e.g. changing the numerator by 10 cells.
=D11/SUM(D$1:D$4)
=D12/SUM(D$1:D$4)
=D13/SUM(D$1:D$4)
=D14/SUM(D$1:D$4)
=D15/SUM(D$5:D$9)
=D16/SUM(D$5:D$9)
=D17/SUM(D$5:D$9)
=D18/SUM(D$5:D$9)
=D19/SUM(D$5:D$9)
or, changing the base by 100. e.g.
=D1/SUM(D$100:D$104)
=D2/SUM(D$100:D$104)
=D3/SUM(D$100:D$104)
=D4/SUM(D$100:D$104)
=D5/SUM(D$105:D$109)
=D6/SUM(D$105:D$109)
=D7/SUM(D$105:D$109)
=D8/SUM(D$105:D$109)
=D9/SUM(D$105:D$109)
Sometimes, both. Any guidance on how this can be possible?
Thank you.
the first part of this problem seems easy unless I am missing something?
Part 1:
Since the denominator is already in $x form, you can select and COPY the whole range of formulas and PASTE them 10 rows down and then CUT and paste it back into position. The COPY will update the numerators appropriately and when you CUT and PASTE it back into position they will now be just as you want? The second question will be a bit more of a challenge!
Part 2:
OK without VBA I can only think of a really long-winded way to change your demoninators, but I just checked that it does work:
To change the bottom.
Search and replace = with '=
Now you can edit the formulas more freely.
Search and replace D with D%
Search and replace D%$ with D
Search and replace D% with D$
get rid of the '= by using the Data>text to columns option
Now use the copy and paste, cut paste trick from part 1.
Then if you still need your $s back as they were you essentially repeat 1 to 5 again.
Sorry, this looks really long-winded, but if you are desperate and back up before you start it should work.
An excel formula can't replace another cells excel formula... One approach is to make the formula into text and then transform it by other formulas. When transformation is done, you could paste the formula back.
So for changing the D1 -> D11, I would build a dummy series (column K) then write a formula (cell L1). Then I can copy the formula and paste it into the correct column.
Replaceing the "=", with a special character and then you can transform the formulas.
(Column F).
In Column I, the formula used is: =RIGHT(F1,LEN(F1)-FIND("/",F1))
For changing D$1 -> D$100, I think I just would copy and replace it by searching in "Formulas".
This approach can be feasible for acouple of hundred cells. If the list is very long, I would recommend some VBA solution, where you can grab a cells formula with .Range("A1").Formula

Excel How to find more values that contain values in the cell next to them?

I want to use the Index formula to list data in my excel sheet.
I want to list the data of the column A that contains "finished" in the corresponding cells in column E.
Currently I'm using the following formula:
=INDEX(IMs!A:A;MATCH("finished";IMs!E:E;0))
The problem is, only the first value appears. I want to list ALL of them.
Is it possible with the vlookup formula?
Thank you very much in advance.
Kind regards,
Vanessa
First enter this formula in B1:
=COUNTIF(IMs!$E:$E,"Finished")
Then enter this array formula** in your first cell of choice:
=IF(ROWS($1:1)>$B$1,"",INDEX(IMs!$A$1:$A$1000,SMALL(IF(IMs!$E$1:$E$1000="finished",ROW(IMs!$E$1:$E$1000)-MIN(ROW(IMs!$E$1:$E$1000))+1),ROWS($1:1))))
Copy this formula down (though not the one in C1) until you start to get blanks for the results.
If the upper row reference that I chose (1000) is not sufficiently high, then change it as required. Note, however, that since this is an array formula, it is not recommended that you make this upper bound too high (and certainly don't reference entire columns!), since this will have a significantly detrimental effect on spreadsheet performance.
From your post, it also appears that you are using a version of Excel in which the argument separator in formulas is not the comma but the semi-colon. If this is indeed the case then you will need to make the necessary amendments to the formulas I provided.
Regards
**Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).

EXCEL 2010 - Return Highest Value that is NOT a complete number

I'm using excel 2010.
I need a formula that will return the highest value of a mixed variable.
Look up VFL will return VFL00151
A1 VFL00001
A2 VWS00004
A3 VSC00056
A4 VFL00151
A5 VCC10025
A6 VGH00122
I'm avoiding using macros.
Thanks
With Col_A referring to your range in column A, and the lookup value (VFL) in C1, the following array formula (entered by holding down ctrl-shift while hitting enter, the following formula will perform as you request:
=IF(MAX(N(ISNUMBER(SEARCH(C1,Col_A))))=0,"",INDEX(Col_A,MATCH(MAX(IF(ISNUMBER(SEARCH(C1,Col_A)),--MID(Col_A,4,99),0)),IF(ISNUMBER(SEARCH(C1,Col_A)),--MID(Col_A,4,99),0),0)))
Of course, this assumes all of your entries start with three letters, and then are followed by digits.
Also, using the same set-up and assumptions as Ron Rosenfeld, but also assuming you're using Excel 2007 or later, array formula**:
=IF(COUNTIF(Col_A,C1&"*")=0,"",INDEX(Col_A,MATCH(1,(LEFT(Col_A,3)=C1)*(0+MID(Col_A,4,99)=MAX(IFERROR(0+SUBSTITUTE(Col_A,C1,""),0))),0)))
Note also that this solution is case-sensitive whereas Ron Rosenfeld's is not.
Regards
**Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).
=MAX(--MID(A1:A6,4,LEN(A1:A6)-3))
ctrl+shitf+enter when you've entered the formula, to create an array formula. This assumes that all of your numbers have the same form, of 3 letters, then your number.
The mid formula takes the numeric part, based on the pattern you've outlined above. If the pattern is not consistent, you've got less hope with a formula. Doing this as an array, does all of the cells in the range in one step, and returns an array of numbers. This can then be 'maxed'
Update. To take this a step further, and do a lookup on the same principle (without error handling):
=INDEX(A1:A6,MATCH(MAX(--MID(A1:A6,4,LEN(A1:A6)-3)),--MID(A1:A6,4,LEN(A1:A6)-3),0))

Excel - sum of what range is closest to 50%

I have % values in cells A1:A60 (sum = 100%). I want to find out what range (starting from A1 downwards) will get me closest to 50%.
For example if Sum(A1:A32)=0.482 and Sum(A1:A33)=0.52, I would want it to return range A1:A32 (in actual fact, I'd want it to return the value 32 that represents the bottom of this range).
This formula needs to be repeatable over many such 1-dimensional ranges, so a 'solve' method isn't really what I'm after. I'm hoping for a tidy formula in a single cell for each range.
Many thanks!
P.S. Please assume the distribution of data within each range is random
Best I can do is this array formula**:
=MATCH(TRUE,ABS(B1-SUBTOTAL(9,OFFSET(A1,,,ROW(A1:A60)-MIN(ROW(A1:A60))+1,)))=MIN(ABS(B1-SUBTOTAL(9,OFFSET(A1,,,ROW(A1:A60)-MIN(ROW(A1:A60))+1,)))),0)
where B1 contains your desired threshold, e.g. 0.5.
Regards
**Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).

Using the Mode function with dates (decimal data) in Excel

I have a column of dates in Excel, and there will always be only two dates in the column. I want a formula to return the date that exists most (so if 1/23/13 occurs 24 times and 1/24/13 occurs 72 times, I want the formula to return 1/24/13).
I used the MODE formula across the range, and this worked for a couple days in a row, but today it did not work. Upon further review, I realized the dates are really viewed by Excel as decimal numbers, and I imagine this is the problem.
I could get to what I need by inserting a new column and filling it with =TRUNC(cell) for all cells in the range, and then applying the MODE formula to the new column, but I'm hoping there might be a way to do it without introducing a new column or formulas. Is it possible to do something like =MODE(TRUNC(range))? That specific formula didn't work, but I'm hoping something similar will.
Yes, your suggested formula should work......but it's an "array formula" which means that you need to enter it with a specific key combination.
Paste the formula in the cell then press F2 key to select formula and then hold down CTRL + SHIFT keys and press ENTER. If done correctly that will place curly braces like { and } around the formula in the formula bar.
If you have any blanks in the range then the result may be skewed with
=MODE(TRUNC(range))
so you can change that to
=MODE(IF(range<>"",TRUNC(range)))

Resources