Model that can change when data is filtered

ACF0303

New Member
Joined
Aug 29, 2013
Messages
41
I have built a model that is linked to a sheet of data. What I would like to do is let someone filter the data, say by state and then have the model change from showing all results to just those filtered results. The tricky part is that I need to use the countif and sumif functions to tell the resulting data where to go in the model. So, for example, I have a bunch of data in column D. The data could get filtered by columns A- C. The model then says, count the data points in column D if column I is "31." I have tried some of the suggestions offered, but I'm doing something wrong. I would be grateful for any suggestions.
 

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).
Instead of countif, try:
[TABLE="width: 64"]
<colgroup><col width="64"></colgroup><tbody>[TR]
[TD="class: xl63, width: 64"]=SUMPRODUCT(SUBTOTAL(3,OFFSET(D2,ROW(D2:D5000)-ROW(D2),0)),--(I2:I5000<>""))[/TD]
[/TR]
</tbody>[/TABLE]
This assumes the headers are in row 1 and the data in rows 2 thru 5000 - adjust to your actual data.

For the sumif formula, change the 3 to 9 like this:
[TABLE="width: 64"]
<colgroup><col width="64"></colgroup><tbody>[TR]
[TD="class: xl65, width: 64"]=SUMPRODUCT(SUBTOTAL(9,OFFSET(D2,ROW(D2:D5000)-ROW(D2),0)),--(I2:I5000<>""))
[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
Instead of countif, try:
[TABLE="width: 64"]
<tbody>[TR]
[TD="class: xl63, width: 64"]=SUMPRODUCT(SUBTOTAL(3,OFFSET(D2,ROW(D2:D5000)-ROW(D2),0)),--(I2:I5000<>""))[/TD]
[/TR]
</tbody>[/TABLE]
This assumes the headers are in row 1 and the data in rows 2 thru 5000 - adjust to your actual data.

For the sumif formula, change the 3 to 9 like this:
[TABLE="width: 64"]
<tbody>[TR]
[TD="class: xl65, width: 64"]=SUMPRODUCT(SUBTOTAL(9,OFFSET(D2,ROW(D2:D5000)-ROW(D2),0)),--(I2:I5000<>""))[/TD]
[/TR]
</tbody>[/TABLE]

Thanks so much! One quick clarification....what does the <>"" indicate? Would I simply adjust to =31?
 
Upvote 0
Thanks so much! Works like a charm. Have you had issues with Excel running out of resources to do the calculations?
 
Upvote 0
You're welcome.

Excel has run out of resources for me sometimes if I've used thousands of volatile functions like VLOOKUP or SUMPRODUCT or others. Sometimes I could switch to other functions and sometimes I could break up the file into 2 or more files. What is the situation you're experiencing?
 
Upvote 0
So far the model has a number of macros, sum, countif, etc and 45 instances of the formula you helped me with. The challenge is if I have 100000+ lines of data. Am I heading into "have a programmer build something" territory.
 
Upvote 0
You can try to find out what is causing the slowdown by systematically deleting one thing and seeing if that speeds up the worksheet. For example, using a copy of your slow worksheet (don't do this with the original) apply "copy/paste-values" to a column or group of columns with formulas and see if there's a noticeable improvement in speed. Continue the copy/paste-values with additional columns until you either find the problem or confirm the formula's are not the cause. Disable all macros to see if that's the cause - if it is, then zero in on which specific macro(s) are the cause. Delete pivot tables to see the speed impact. Delete 90,000 of the 100,000 rows to see it's impact on speed. See if hardware might be the problem by running it on a known faster computer, looking at how large in MB is the file size, how much memory your computer has, does it speed up if your computer does not have anything else open, etc.
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

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