Dynamic sum function [closed] - excel

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm working on a spreadsheet where I would like to be able to sum a certain number of cells automatically. E.g. I put in 120 or 100 in my reference cell and Excel then gives me the sum of the top 120 or 100 cells in my revenue column. Is there a way to do this? I've thought about simply naming the range of cells like "top120revenue" and "top100revenue" etc. but besides being static it is also complicated when working with 27 sheets. If a formula exists it would be easier to simply change the sheet reference instead of relabeling the range of cells. Maybe the answer lies in VBA but I'm by no means an expert there
Hope someone can help!?

Do you mean the top n cells positionally or the n highest values? If it's the former I would use INDEX which is a little more robust than INDIRECT i.e.
=SUM(A1:INDEX(A:A,B1))
If you mean the n largest values then try
=SUMPRODUCT(LARGE(A:A,ROW(INDIRECT("1:"&B1))))

I think I found the answer to your question here. It uses the function INDIRECT().
For example: if column A holds your data and B1 is your reference cell containing the value 100, then the formule below gives the sum of the first 100 values of column A.
=SUM(A1:INDIRECT("A"&B1))
This gets interpreted as:
=SUM(A1:A100)

Related

Excel - How to calculate the sum of values in a table based on text from the same cells as the value? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 months ago.
Improve this question
I need to calculate the sum of values in a range of cells, which have different and/or identical data, based on text that is in the same cells as the value I need calculated.
I have created 4 sheets: data, control, test and result; with more than 5 mil cells with formulas(mostly typed because of errors) and I need to extend the range of all sheets.
Is there a simpler way(than what I've made) to achieve the results from column B?
Thanks.
If you want column B to have that number, then
=left(A2,1)*1
will work.
If the number is 2 digits then you will have to test and deal with that.
Then sum column B:
=sum(B:B)

How do I multiply cell by cell values when both cells lie in range in google spreadsheet? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I want to multiply values in cells row by row and total them up in the resulting cell below, what is the formula?
the first column is ranging a1:a4, the second column ranging b1:b4.
I can write this: =((a1*b1) + (a2*b2) + (a3*b3)).
But i want nice and clean formula that uses ranges, like =( (a1:a3)*(b1:b3))
but it does not work
Figured this out quickly myself, fortunately google uses similar formulas as in excel.
Excel has this nice SUMPRODUCT(array1,array2) which multiplies row by row and sum it up.
so the answer is this: SUMPRODUCT(A1:A5,B1:B5)

Excel: Ignore text in a cell, count only number in the cell [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I have a range of cells I need to average. Most cells contain 0, 1, or 0.5. Some cells contain something like "0 - absent" or "0.5 - late". I would like to include these cells in the average, however the text complicates it. What formula can I use to count only the numbers in order to get an average?
The following formula will produce the average you want if your data contain no blank cells. For simplicity, I've assumed your data are in the range A1:A6.
=AVERAGE(IFERROR(VALUE(LEFT(A1:A6,SEARCH(" ",A1:A6)-1)),A1:A6))
If you do have blank cells in the data range, the formula should be modified to:
=AVERAGE(IF(ISBLANK(A1:A6),"",IFERROR(VALUE(LEFT(A1:A6,SEARCH(" ",A1:A6)-1)),A1:A6)))
These are array formulas and would need to be entered with the Control-Shift-Enter key combination.
Here's one approach; but it requires the use of an additional column
note the formula is listed up top and it assumes consistent mask of fields with text data of # space dash space text. you have to do an math function to convert the string data to text data or it is excluded in the avg; thus the *1 in the formula when text data is present.

Excel vlookup() the right function to use? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm not sure if VLOOKUP() is the function I am looking for, but here is the spreadsheet that I am working on: https://docs.google.com/spreadsheet/ccc?key=0Ap96QeCBYRNtdDlpX0lONDg1YThLN1M5YkNlT1FBeFE
What I am basically trying to do is use the values in cells E18:P18 to determine whether or not my values in cells E4:P7 should be replaced or not. If there is a value other than 0 in that range, then it should take the values from the appropriate column in the range of E13:P16 and replace them into the appropriate item.
So, for this example, we are replacing item values 1 (weapon #1), 3 (off-hand), 4 (helm), and 5 (shoulders). The expected results can be seen on the spreadsheet and these are the values that I would like to show up in the Equipped Item. Is there a way to easily achieve this through an excel formula? If so, what is the best way to use it?
After our discussion, here's what I think you should do.
In the Expected Results table, try this formula out in cell E31:
=IFERROR(INDEX($E$17:$P$20,ROWS($1:1),MATCH(VLOOKUP(E$30,$A$4:$B$17,2,FALSE),$E$22:$P$22,0)),E4)
Once you paste it in, you can copy down and the formula will adjust accordingly.
Here is a picture of the expected results based on your info:
Please let me know if this is the desired result :)

How do I get to display the last date that has a corresponding value in another column in excel? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I have a excel spreadsheet with dates in one column, and results/values in another column (not next to each other, but on the same sheet). I want to set up a little summary table that will display the last date that had a corresponding result in the results column, since the latest date does not always have results available immediately. I would appreciate any help on this.
You can achieve this with an array formula.
=MAX(IF(B3:B12<>"";A3:A12;0))
Important with an array formula is that you finish entering by Control + Shift + Enter!! The formula will then be automatically enclosed in curly brackets. If you press only enter it will work as a normal formula.
What the formula will do:
The if will go through the range and if the cell content meets your condition then it puts the value from the according cell in the second array into his result array otherwise it puts in 0.
Then the MAX command is working on the resulting array. Important is that the arrays used in the array formula are the same size!

Resources