Multiple Filter Combo Box Form Controls, Dynamic COUNTIFS Array Formulas

JohnnyAngel

Board Regular
Joined
Apr 18, 2011
Messages
65
All,

I need the filter VBA macro code assigned to each filter in the DB tab to be modified to clear the filter from the DATA Tab when "ALL" is selected. Right now, it filters all other selections, but when I select "ALL", the DATA Tab still shows the database filtered and I need it to show all records when nothing is selected from all (3) drop down menus of each filter.

Code:
Option Explicit

Sub Filter1()
With Sheets("DATA")
     If .FilterMode Then .ShowAllData
     .Range("B3").AutoFilter
 .Range("$B$3").CurrentRegion.AutoFilter Field:=1, _
     Criteria1:=Range("Filter1").Cells(Sheets("DB").Cells(1, 1).Value)
 End With
End Sub
Sub Filter2()
With Sheets("DATA")
     If .FilterMode Then .ShowAllData
       .Range("B3").AutoFilter
 .Range("$B$3").CurrentRegion.AutoFilter Field:=2, _
     Criteria1:=Range("Filter2").Cells(Sheets("DB").Cells(2, 1).Value)
 End With
End Sub

Sub Filter3()
With Sheets("DATA")
     If .FilterMode Then .ShowAllData
       .Range("B3").AutoFilter
 .Range("$B$3").CurrentRegion.AutoFilter Field:=3, _
     Criteria1:=Range("Filter3").Cells(Sheets("DB").Cells(3, 1).Value)
 End With
End Sub



Additionally, I need the #1) COUNTIF Array formula to be modified as follows:

#1)

Change This: {=(COUNT(IF(RngVal1>=$G$19,IF(RngVal1<=$G$18,1,0))))/G15}

To Something LIke This: {=(COUNT(IF(SUBTOTAL(3,OFFSET(RngVal1>=$G$19,IF(RngVal1<=$G$18,1,0))))/G15}

I want the above array formula to look something like the array formula below, so I can test the accuracy of its count because #1 & #2 are returning different results.

#2)

=SUMPRODUCT(SUBTOTAL(3,OFFSET(RngVal1,ROW(RngVal1)-MIN(ROW(RngVal1)),,1)),--(RngVal1>=$G$19),--(RngVal1<=$G$18)/G15

The Problem:

The 1st formula is counting 164 instances. The 2nd formula one is counting 141. I need to find out which one is accurate and is going to be the best solution for when the database is filtered. Bottomline, when the filters are set, the COUNTIFS array formula with multiple conditions, should return the correct count according to the filtered data scope.

For instance, if the filter returns 10 records, the COUNTIF array should tell me how many of those 10 records meet the criteria from the COUNTIFS Array Formula that contains the multiple conditions.

I have attached the XL file with more clarification and questions regarding this initiative.

Thanks,
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

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