How to write sum if formula if criteria is a variable parameter?

Iris14

New Member
Joined
Feb 16, 2014
Messages
11

<colgroup><col><col span="3"></colgroup><tbody></tbody>
I have a Table 1 which contained the sub account number and the related amount. The sub account numbers are then grouped to a master account number which is presented in Table 2. Table 2 is like a directory to guide what sub account numbers need to be added together.

Table 1
Sub Account numberAmount
SDFG1
D2
FG3
D6
GH8
T854
RH565
H45
GH546
GH54
J5
GH2

<colgroup><col><col></colgroup><tbody>
</tbody>

Table 2
Master account 1GHJT

<colgroup><col><col span="3"></colgroup><tbody>
</tbody>


I would like to do a sum if formula to sum the amount in table 1 if column A of Table 1 (the sub account number) matches any of the account number in row 1 of Table 2.

The number of sub account number in the Master account is variable.

I have tried to build array formula like {=SUM(IF(A:A={"GH","J","T"},B:B,0))}
But then the account number would need to be keyed in manually and there are a lot of sub account numbers that needed to be built into the formula.

I would like to ask if there is anyway to build formula, e.g. match, address, lookup, index and etc to do the work (adding the amount in table 1 of any sub account numbers that belong to the same master account).

Thank you very much for any help!!!
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
try something like this

=SUM(IF(ISERROR(MATCH(A:A,C1:F1,0))=FALSE,B:B,0))
C1:F1 consist of those {"GH","J","T"} letters
 
Upvote 0
couple of other options



Excel 2007
ABCDEF
1Sub Account numberAmountGHJT
2SDFG1
3D2
4FG3
5D6
6GH8
7T854
8RH565
9H45
10GH546
11GH54
12J5
13GH2
141469
151469
Sheet1
Cell Formulas
RangeFormula
D14=SUMIF(A2:A13,D1,B2:B13)+SUMIF(A2:A13,E1,B2:B13)+SUMIF(A2:A13,F1,B2:B13)
D15=SUMPRODUCT(--(A2:A13=D1)+(A2:A13=E1)+(A2:A13=F1),B2:B13)
 
Upvote 0
Assuming your values are in Row 1 of Table2:

=SUMPRODUCT((A2:A12=Table2!1:1)*B2:B12)
 
Upvote 0
Thanks a lot vlady for your prompt reply !!! It works !!! Thanks a lot for your great help !!! It is very much appreciated.
 
Upvote 0
Thank you all for the prompt reply !!! It is a great forum. I definitely find the right spot !:cool:
 
Upvote 0

Forum statistics

Threads
1,215,430
Messages
6,124,850
Members
449,194
Latest member
HellScout

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