Addition based on the column heading

snjpverma

Well-known Member
Joined
Oct 2, 2008
Messages
1,584
Office Version
  1. 365
Platform
  1. Windows
Excel Workbook
ABCDEFGHI
1BaseBaseBase
2837051735168849282
3678084836377508056
Sheet1



In the above data, A1, E1 and G1 is updated as "Base". Cell G1 is the left most column among them. Please suggest a formula to get the sum of the values in the row 2 and 3 from the left most column with text "Base". in the above case my return value will be +84+50 i.e. G2+G3 = 134..

I am not good at excel. So, please help
 
In A12 enter and copy across:

=IF(A$1="base",SUMPRODUCT(--ISNUMBER(MATCH(ROW(A$2:A$11),{2;3;7;8;10},0)),A$2:A$11),"")
The above given formula calculates the specified rows from Column A. However, as highlihgted in Post #7, the formula should calculate the total from the column which has the left-most column as "Base". A1, E1 and G1 have the text "Base" in it but the left most is G1. Hence add the {2;3;7;8;10} of column G. Please refer the table pasted in post #7 and not post #1. Thanks for your efforts Aladin.
 
Last edited:
Upvote 0

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Try,

=SUM(N(OFFSET(INDEX(A1:I1,0,MATCH(2,INDEX(1/(A1:I1="Base"),0))),{1,2,6,7,9},0)))

Regards
 
Upvote 0
The above given formula calculates the specified rows from Column A. However, as highlihgted in Post #7, the formula should calculate the total from the column which has the left-most column as "Base". A1, E1 and G1 have the text "Base" in it but the left most is G1. Hence add the {2;3;7;8;10} of column G. Please refer the table pasted in post #7 and not post #1. Thanks for your efforts Aladin.

Efforts?...

Did you enter the formula:

=IF(A$1="base",SUMPRODUCT(--ISNUMBER(MATCH(ROW(A$2:A$11),{2;3;7;8;10},0)),A$2:A$11),"")

in A2 and copied across? If you did, what was wrong?
 
Upvote 0
Efforts?...

Did you enter the formula:

=IF(A$1="base",SUMPRODUCT(--ISNUMBER(MATCH(ROW(A$2:A$11),{2;3;7;8;10},0)),A$2:A$11),"")

in A2 and copied across? If you did, what was wrong?

Aladin, i can surely use your formula in A11 to I11 which would be my helper row. But eventually I would need one more formula which would give me the real output.

Using Bosco's formula it goes like this.
K2 - Bosco's formula = Output

Since i am not that good at excel formulas, I don't know what the second formula would have been if I go by your method.

Nevertheless, I highly appreciate your support.
 
Last edited:
Upvote 0
Aladin, i can surely use your formula in A11 to I11 which would be my helper row. But eventually I would need one more formula which would give me the real output.

Using Bosco's formula it goes like this.
K2 - Bosco's formula = Output

Since i am not that good at excel formulas, I don't know what the second formula would have been if I go by your method.

Nevertheless, I highly appreciate your support.

No need. I got it now.
 
Upvote 0
I used this {1,2,6,7,9} in the below formula to sum the value in those rows.
=SUM(N(OFFSET(INDEX(A1:I1,0,MATCH(2,INDEX(1/(A1:I1="Base"),0))),{1,2,6,7,9},0)))

I would like to know if there is a way to sum a range using this? For example. Instead of rows 1,2,6,7,9 how can I put rows 2 to 8 and 10. I used {2:8, 10} in the above formula but in vain. Please advise
 
Upvote 0
I used this {1,2,6,7,9} in the below formula to sum the value in those rows.
=SUM(N(OFFSET(INDEX(A1:I1,0,MATCH(2,INDEX(1/(A1:I1="Base"),0))),{1,2,6,7,9},0)))

I would like to know if there is a way to sum a range using this? For example. Instead of rows 1,2,6,7,9 how can I put rows 2 to 8 and 10. I used {2:8, 10} in the above formula but in vain. Please advise

is the expected value 2375 for the last you posted?
 
Upvote 0
Hi Aladin, My expected answer is 2270 i.e. sum of G2:G8 and G10. You seem to have added G3:G9 and G11.

Those numbers, 2 to 8, and 10 are thus native row numbers. If so...

In K1 just enter:

=LOOKUP(9.99999999999999E+307,SEARCH("base",A1:I1),COLUMN(A1:I1)-COLUMN(A1)+1)

For the sum, control+shift+enter, not just enter:

=SUMPRODUCT(INDEX(A2:I11,0,K1),IF(ISNUMBER(MATCH(ROW(A2:I11),{2;3;4;5;6;7;8;10},0)),1,0))
 
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top