"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 |
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 |
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 |
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 |
All times are GMT +1. The time now is 09:36 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com