?
Solved

Excel SumProduct using CountA

Posted on 2012-08-21
5
Medium Priority
?
443 Views
Last Modified: 2012-08-29
What is the correct way to use CountA for a dynamic row in a SumProduct?

This works fine;

=SUMPRODUCT((Data!$I$2:$IJ$66)*(Data!$I$1:$IJ$1=Sumary!D$1)*(Data!$G$2:$G$66=Sumary!$A7)*(Data!$A$2:$A$66="D"))

but this gives me a #VALUE error;

=SUMPRODUCT(("Pnl!$I$2:$IJ$" & COUNTA(Data!$G:$G))*(Data!$I$1:$IJ$1=Sumary!D$1)*("Pnl!$G$2:$G$" & COUNTA(Data!$G:$G)=Sumary!$A6)*("Pnl!$A$2:$A$" & COUNTA(Data!$G:$G)="D"))

even though my CountA=66
0
Comment
Question by:newparadigmz
5 Comments
 
LVL 24

Expert Comment

by:Steve
ID: 38317505
I think you would need to use the Offset function:

Which would be easier if you set dynamic named ranges first, then used those in the formula.
0
 
LVL 50

Expert Comment

by:barry houdini
ID: 38317560
Try putting the COUNTA formula in a cell, e.g. Z2  and then use this version

=SUMPRODUCT((Data!$I$1:$IJ$1=Sumary!D$1)*(Data!$G$2:INDEX(Data!$G:$G,$Z$2)=Sumary!$A7)*(Data!$A$2:INDEX(Data!$A:$A,$Z$2)="D"),Data!$I$2:INDEX(Data!$IJ:$IJ,$Z$2))

If you don't want a reference cell just put COUNTA(Data!$G:$G) in place of the three $Z$2s

regards, barry
0
 
LVL 1

Expert Comment

by:nombplum
ID: 38318795
I agree with The_Barman.  I frequently used dynamic named ranges for such tasks.  See the following link explaining how do define these dynamic ranges from the Microsoft website.

This greatly simplifies formulas.

http://support.microsoft.com/kb/830287

Regards.
0
 

Author Comment

by:newparadigmz
ID: 38322472
@ barry, this didn't work for me. does it work for you?

"If you don't want a reference cell just put COUNTA(Data!$G:$G) in place of the three $Z$2s"
0
 
LVL 50

Accepted Solution

by:
barry houdini earned 2000 total points
ID: 38322923
Yes, works for me, see attached

The formula in D7 copied across and down is the same as suggested above, then the versions in D14:F16 are the same. Highlighted cells E7 and E14 pick up the highlighted values from the Data sheet, so D14 is this version

=SUMPRODUCT((Data!$I$1:$IJ$1=Sumary!D$1)*(Data!$G$2:INDEX(Data!$G:$G,COUNTA(Data!$G:$G))=Sumary!$A7)*(Data!$A$2:INDEX(Data!$A:$A,COUNTA(Data!$G:$G))="D"),Data!$I$2:INDEX(Data!$IJ:$IJ,COUNTA(Data!$G:$G)))

You may also want to check out the dynamic ranges suggested by others here - you can use effectively the same formula but define

Headers as =Data!$I$1:$IJ$1
Range1 as =Data!$G$2:INDEX(Data!$G:$G,COUNTA(Data!$G:$G))
Range2 as =Data!$A$2:INDEX(Data!$A:$A,COUNTA(Data!$G:$G))

and

Range3 as =Data!$I$2:INDEX(Data!$IJ:$IJ,COUNTA(Data!$G:$G))

then you get just

=SUMPRODUCT((Headers=Sumary!D$1)*(Range1=Sumary!$A7)*(Range2="D"),Range3)

regards, barry
Dynamic-range-example.xlsx
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question