Computing.Net > Forums > Office Software > Sum a variable range of cells??

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Sum a variable range of cells??

Reply to Message Icon

Name: confused725
Date: September 6, 2007 at 02:02:16 Pacific
OS: XP
CPU/Ram: Athlon XP2100
Comment:

Hi,

I have a worksheet where I would like to sum a set of values but with different variables:-

For example for Row 2 with a condition of 4 I would like to sum cells B2,C2,D2,E2.

However on Row 3 the condition might be 6 so i would want to sum B3,C3,D3,E3,F3,G3.

Can i use a formula to do this, so it determines what the condition is and sums the relevant number of cells.


Thanks



Sponsored Link
Ads by Google

Response Number 1
Name: DerbyDad03
Date: September 6, 2007 at 04:48:31 Pacific
Reply:

We need more info before we can help.
What is the condition? Where is it stored? What causes the condition to be set?

Please be more specific and we'll see what we can do.


0

Response Number 2
Name: DerbyDad03
Date: September 6, 2007 at 06:30:28 Pacific
Reply:

What the heck..I'll take a guess at what you are trying to do and offer this. Let me know if I guessed correctly.

Let's say your data starts in column B and you need to sum a variable number of columns based on the value in column A of the same row. i.e. In your examples, you'd have a 4 in A2 and a 6 in A3.

One way to accomplish what you want is to use Dynamic Named Ranges.

For each row, follow this procedure. My example will be for Row 2. Change the 2 to whatever row(s) you want to this in.

1 - Insert...Name...Define
2 - In the Names field enter a name for the Named Range, such as SumRow2
3 - In the Refers to field, enter =OFFSET($B$2,0,0,1,$A$2)
4 - Click OK
5 - In the cell where you want your sum, put =SUM(SumRow2)
Note: You will get an error in your Sum cell until you actually place a value in A2. This can be fixed with an IF statement if required.

This works because the Named Range will adjust it's width based on the value in A2.

Look up the OFFSET function for more details.



0

Response Number 3
Name: confused725
Date: September 6, 2007 at 07:36:30 Pacific
Reply:

Sorry if I was'nt very clear but you were right. That is just perfect for what I need to do.

Thank you very much!


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Office Software Forum Home


Sponsored links

Ads by Google


Results for: Sum a variable range of cells??

*Color range of cells, merge cells* www.computing.net/answers/office/color-range-of-cells-merge-cells/5624.html

SUMIF or VLOOKUP? a range of cells www.computing.net/answers/office/sumif-or-vlookup-a-range-of-cells/7067.html

Advanced Excel Question www.computing.net/answers/office/advanced-excel-question/5742.html