Solved

add rows with column greater than 3

Posted on 2014-11-03
12
70 Views
Last Modified: 2014-12-15
Dear expert.

The number 1 below is in cell A1 and the number 10 is in cell B1.
I will enter in cell C1 a value from 1 to 6 and in cell D1 there should be a formula that adds rows 1 until the value inputed in C1. The formula sould look at column A and see if the value is less than or equal to value in C1, if so then it should add value in B1, this process should continue for range A1:B6.

Another way, is to have B1 as starting celll, and in C1 enter how many rows down we want sum. Example, if C1 reads 4 then it would sum B1:B4.

Br,
JP

1      10
2      22
3      33
4      44
5      55
6      66
7      77
0
Comment
Question by:easycapital
  • 4
  • 4
  • 2
  • +1
12 Comments
 
LVL 22

Expert Comment

by:Flyster
ID: 40420687
Try this formula in D1:

=SUM(A1:INDIRECT("A"&B1))

Flyster
0
 

Author Comment

by:easycapital
ID: 40420698
If C1 = 3 then D1 should = 10 + 22 + 33
0
 

Author Comment

by:easycapital
ID: 40420699
If C1 = 5 then D1 should = 10 + 22 + 33 + 44 + 55.
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 22

Expert Comment

by:Flyster
ID: 40420705
Here it is for column B:

=SUM(B1:INDIRECT("B"&C1))
0
 
LVL 22

Expert Comment

by:Flyster
ID: 40420713
For the equal to or less that part, try this:

=SUMIF(A1:INDIRECT("A"&C1),"<="&C1,B1:INDIRECT("B"&C1))
0
 
LVL 27

Expert Comment

by:Glenn Ray
ID: 40420734
To get the nth sum of values in column B add this formula to cell D1:
=SUM(INDIRECT("B1:B" & $C$1))

This is a variation of Flyster's post above in 40420705.

Regards,
-Glenn
0
 
LVL 27

Expert Comment

by:Glenn Ray
ID: 40420740
Or, if you wanted to avoid using an INDIRECT function, use this array formula:
=SUM(IF(ROW(B1:B7)<=$C$1,B1:B7,0))

This has to be entered with [Ctrl]+[Shift]+[Enter].
0
 

Author Comment

by:easycapital
ID: 40420989
is there a possibility to the use the SUMIF function?
0
 
LVL 22

Accepted Solution

by:
Flyster earned 500 total points
ID: 40421284
Yes, my sample above is one. This one is for numbers in column A that are less or equal to column C:

=SUMIF(A1:INDIRECT("A"&C1),"<="&C1,B1:INDIRECT("B"&C1))

In case you're wondering, the Indirect function allows you to use a cell value as a reference.
0
 

Author Comment

by:easycapital
ID: 40444318
Will need to check again. I will revert.
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40499964
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question