Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Massimo
 
Posts: n/a
Default "if" formula to sum several cells...

Hi all,

I need to sum some consecutive cells in a row, depending on a number in
another cell.

For instance:
If the cell contains 2 sum A1 + B1
If the cell contains 3 sum A1 + B1 + C1
If the cell contains 4 sum A1 + B1 + C1 + D1
and so on ...

is there a function to do that or vba code needs to be written?

any help will be very much appreciated.

Thanks!
Massimo

  #2   Report Post  
Mangesh Yadav
 
Posts: n/a
Default

Suppose the cell that is supposed to conain 2 or 3 or 4 is A3, then use
formula:

=SUM(A1:OFFSET(A1,0,A3-1))


Mangesh



"Massimo" wrote in message
...
Hi all,

I need to sum some consecutive cells in a row, depending on a number in
another cell.

For instance:
If the cell contains 2 sum A1 + B1
If the cell contains 3 sum A1 + B1 + C1
If the cell contains 4 sum A1 + B1 + C1 + D1
and so on ...

is there a function to do that or vba code needs to be written?

any help will be very much appreciated.

Thanks!
Massimo



  #3   Report Post  
RagDyeR
 
Posts: n/a
Default

With the cell of reference being C1, try this:

=SUM(A1:INDEX(A:A,C1))

--

HTH,

RD
==============================================
Please keep all correspondence within the Group, so all may benefit!
==============================================

"Massimo" wrote in message
...
Hi all,

I need to sum some consecutive cells in a row, depending on a number in
another cell.

For instance:
If the cell contains 2 sum A1 + B1
If the cell contains 3 sum A1 + B1 + C1
If the cell contains 4 sum A1 + B1 + C1 + D1
and so on ...

is there a function to do that or vba code needs to be written?

any help will be very much appreciated.

Thanks!
Massimo


  #4   Report Post  
Massimo
 
Posts: n/a
Default

Thanks Mangesh,
your formula works perfectly.

:))
Massimo



"Mangesh Yadav" wrote:

Suppose the cell that is supposed to conain 2 or 3 or 4 is A3, then use
formula:

=SUM(A1:OFFSET(A1,0,A3-1))


Mangesh



"Massimo" wrote in message
...
Hi all,

I need to sum some consecutive cells in a row, depending on a number in
another cell.

For instance:
If the cell contains 2 sum A1 + B1
If the cell contains 3 sum A1 + B1 + C1
If the cell contains 4 sum A1 + B1 + C1 + D1
and so on ...

is there a function to do that or vba code needs to be written?

any help will be very much appreciated.

Thanks!
Massimo




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
see the cells the formula relates to by double clicking the cell pvagolfer Excel Discussion (Misc queries) 1 May 16th 05 12:25 AM
trying to create an (almost) circular formula between cells and data validated cells with lists KR Excel Worksheet Functions 0 May 12th 05 07:21 PM
Macro or Formula to remove Text from Cells smck Excel Worksheet Functions 6 May 11th 05 03:22 AM
Need a 1 Column multiplication formula for 2600 cells. How? Buckle Excel Worksheet Functions 1 March 25th 05 04:17 PM
How do i select different cells to be use in a formula. Manuel Excel Discussion (Misc queries) 1 January 13th 05 03:52 PM


All times are GMT +1. The time now is 03:09 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"