Re: Advanced filters_VBA - variable dynamic criteria filtering
I have updated the file with information & got it to work up to a point but the filter only work if the data starts with the criteria. I tried to adapt it to below but could not get it to work. From information below you will be able to see the filter proses for criteria entry & where the dynamic data comes in for the filter. In this example it only filers to everything stating with "AFR" not everything that contains "AFR"
VBA Code used ( A12= Country; h5:k6 = criteria range )
Range("A12").CurrentRegion.AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
Range("h5:k6"), Unique:=False
Dynamic values formula ( Cell C6 = Account name )
=IF(C6="","*",C6)
[TABLE="width: 635, align: left"]
<tbody>[TR]
[TD="width: 340, bgcolor: transparent, colspan: 4"]
[TABLE="align: left"]
<tbody>[TR]
[TD="width: 300, bgcolor: transparent"][/TD]
[TD="width: 97, bgcolor: transparent"][/TD]
[TD="width: 39, bgcolor: transparent"][/TD]
[TD="width: 97, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent, colspan: 2"][/TD]
[TD="bgcolor: transparent, align: left"]
[/TD]
[/TR]
[TR]
[TD="bgcolor: transparent"][/TD]
[TD="bgcolor: transparent, align: left"]
[/TD]
[/TR]
</tbody>[/TABLE]
<tbody>
[TD="width: 326, bgcolor: transparent"]
Summary / Evaluation Overview
[/TD]
</tbody>
[/TD]
[TD="width: 144, bgcolor: transparent, colspan: 2"]
Based on this input
[/TD]
[TD="width: 217, bgcolor: transparent, colspan: 4"]
Currently it only filter to fields starting with "AFR", ignoring the rest
[/TD]
[TD="width: 146, bgcolor: transparent, colspan: 2"]
[/TD]
[/TR]
[TR]
[TD="width: 76, bgcolor: transparent"][/TD]
[TD="width: 68, bgcolor: transparent"][/TD]
[TD="width: 112, bgcolor: transparent"][/TD]
[TD="width: 85, bgcolor: transparent"][/TD]
[TD="width: 104, bgcolor: transparent"][/TD]
[TD="width: 40, bgcolor: transparent"][/TD]
[TD="width: 38, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 66, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[TD="width: 91, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="width: 76, bgcolor: transparent"]
Selections
[/TD]
[TD="width: 68, bgcolor: transparent"][/TD]
[TD="width: 112, bgcolor: transparent"][/TD]
[TD="width: 85, bgcolor: transparent"][/TD]
[TD="width: 104, bgcolor: transparent"][/TD]
[TD="width: 78, bgcolor: transparent, colspan: 2"]
It must filter to this
[/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 66, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[TD="width: 91, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="width: 340, colspan: 4"]
[/TD]
[TD="width: 104, bgcolor: transparent"][/TD]
[TD="width: 40, bgcolor: transparent"][/TD]
[TD="width: 38, bgcolor: transparent"][/TD]
[TD="width: 180, colspan: 3"]
Criteria - In sheet filter
[/TD]
[TD="width: 64"]
[/TD]
[TD="width: 91, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="width: 76"]
[/TD]
[TD="width: 68"]
[/TD]
[TD="width: 112"]
Account name
[/TD]
[TD="width: 85"]
[/TD]
[TD="width: 104, bgcolor: transparent"][/TD]
[TD="width: 40, bgcolor: transparent"][/TD]
[TD="width: 38, bgcolor: transparent"][/TD]
[TD="width: 57"]
[/TD]
[TD="width: 66"]
[/TD]
[TD="width: 57"]
[/TD]
[TD="width: 64"]
[/TD]
[TD="width: 91, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="width: 76"]
[/TD]
[TD="width: 68"]
[/TD]
[TD="width: 112"]
AFR
[/TD]
[TD="width: 85"]
[/TD]
[TD="width: 104, bgcolor: transparent"][/TD]
[TD="width: 40, bgcolor: transparent"][/TD]
[TD="width: 38, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"]
*
[/TD]
[TD="width: 66, bgcolor: transparent"]
*
[/TD]
[TD="width: 57, bgcolor: transparent"]
AFR
[/TD]
[TD="width: 64, bgcolor: transparent"]
*
[/TD]
[TD="width: 91, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="width: 76, bgcolor: transparent"][/TD]
[TD="width: 68, bgcolor: transparent"][/TD]
[TD="width: 112, bgcolor: transparent"][/TD]
[TD="width: 85, bgcolor: transparent"][/TD]
[TD="width: 104, bgcolor: transparent"][/TD]
[TD="width: 40, bgcolor: transparent"][/TD]
[TD="width: 38, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 66, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[TD="width: 91, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="width: 444, colspan: 5"]
Summary selection for filtered information
[/TD]
[TD="width: 40, bgcolor: transparent"][/TD]
[TD="width: 38, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 66, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[TD="width: 91, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="width: 76"]
[/TD]
[TD="width: 68"]
[/TD]
[TD="width: 112"]
[/TD]
[TD="width: 85"]
[/TD]
[TD="width: 104"]
[/TD]
[TD="width: 40, bgcolor: transparent"][/TD]
[TD="width: 38, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 66, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[TD="width: 91, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="width: 76"]
[/TD]
[TD="width: 68"]
[/TD]
[TD="width: 112"]
[/TD]
[TD="width: 85"]
[/TD]
[TD="width: 104"]
[/TD]
[TD="width: 40, bgcolor: transparent"][/TD]
[TD="width: 38, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 66, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[TD="width: 91, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="width: 76"]
[/TD]
[TD="width: 68"]
[/TD]
[TD="width: 112"]
[/TD]
[TD="width: 85"]
[/TD]
[TD="width: 104"]
[/TD]
[TD="width: 40, bgcolor: transparent"][/TD]
[TD="width: 38, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 66, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[TD="width: 91, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="width: 76"]
[/TD]
[TD="width: 68"]
[/TD]
[TD="width: 112"]
Account name
[/TD]
[TD="width: 85"]
[/TD]
[TD="width: 104"]
Val1
[/TD]
[TD="width: 40, bgcolor: transparent"][/TD]
[TD="width: 38, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 66, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[TD="width: 91, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="width: 76"]
[/TD]
[TD="width: 68"]
[/TD]
[TD="width: 112"]
African-East
[/TD]
[TD="width: 85"]
[/TD]
[TD="width: 104"]
500
[/TD]
[TD="width: 40, bgcolor: transparent"][/TD]
[TD="width: 38, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 66, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[TD="width: 91, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="width: 76"]
[/TD]
[TD="width: 68"]
[/TD]
[TD="width: 112"]
African-East
[/TD]
[TD="width: 85"]
[/TD]
[TD="width: 104"]
550
[/TD]
[TD="width: 40, bgcolor: transparent"][/TD]
[TD="width: 38, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 66, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[TD="width: 91, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="width: 76"]
[/TD]
[TD="width: 68"]
[/TD]
[TD="width: 112"]
African-East
[/TD]
[TD="width: 85"]
[/TD]
[TD="width: 104"]
605
[/TD]
[TD="width: 40, bgcolor: transparent"][/TD]
[TD="width: 38, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 66, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[TD="width: 91, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="width: 76"]
[/TD]
[TD="width: 68"]
[/TD]
[TD="width: 112"]
African-East
[/TD]
[TD="width: 85"]
[/TD]
[TD="width: 104"]
666
[/TD]
[TD="width: 40, bgcolor: transparent"][/TD]
[TD="width: 38, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 66, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[TD="width: 91, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="width: 76"]
[/TD]
[TD="width: 68"]
[/TD]
[TD="width: 112"]
East-Africa
[/TD]
[TD="width: 85"]
[/TD]
[TD="width: 104"]
600
[/TD]
[TD="width: 40, bgcolor: transparent"][/TD]
[TD="width: 38, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 66, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[TD="width: 91, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="width: 76"]
[/TD]
[TD="width: 68"]
[/TD]
[TD="width: 112"]
East-Africa
[/TD]
[TD="width: 85"]
[/TD]
[TD="width: 104"]
660
[/TD]
[TD="width: 40, bgcolor: transparent"][/TD]
[TD="width: 38, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 66, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[TD="width: 91, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="width: 76"]
[/TD]
[TD="width: 68"]
[/TD]
[TD="width: 112"]
East-Africa
[/TD]
[TD="width: 85"]
[/TD]
[TD="width: 104"]
726
[/TD]
[TD="width: 40, bgcolor: transparent"][/TD]
[TD="width: 38, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 66, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[TD="width: 91, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="width: 76"]
[/TD]
[TD="width: 68"]
[/TD]
[TD="width: 112"]
East-Africa
[/TD]
[TD="width: 85"]
[/TD]
[TD="width: 104"]
799
[/TD]
[TD="width: 40, bgcolor: transparent"][/TD]
[TD="width: 38, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 66, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[TD="width: 91, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="width: 76"]
[/TD]
[TD="width: 68"]
[/TD]
[TD="width: 112"]
AFR
[/TD]
[TD="width: 85"]
[/TD]
[TD="width: 104"]
850
[/TD]
[TD="width: 40, bgcolor: transparent"][/TD]
[TD="width: 38, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 66, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[TD="width: 91, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="width: 76"]
[/TD]
[TD="width: 68"]
[/TD]
[TD="width: 112"]
AFR
[/TD]
[TD="width: 85"]
[/TD]
[TD="width: 104"]
935
[/TD]
[TD="width: 40, bgcolor: transparent"][/TD]
[TD="width: 38, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 66, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[TD="width: 91, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="width: 76"]
[/TD]
[TD="width: 68"]
[/TD]
[TD="width: 112"]
AFR
[/TD]
[TD="width: 85"]
[/TD]
[TD="width: 104"]
1,029
[/TD]
[TD="width: 40, bgcolor: transparent"][/TD]
[TD="width: 38, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 66, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[TD="width: 91, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="width: 76"]
[/TD]
[TD="width: 68"]
[/TD]
[TD="width: 112"]
AFR
[/TD]
[TD="width: 85"]
[/TD]
[TD="width: 104"]
1,131
[/TD]
[TD="width: 40, bgcolor: transparent"][/TD]
[TD="width: 38, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 66, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[TD="width: 91, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="width: 76"]
[/TD]
[TD="width: 68"]
[/TD]
[TD="width: 112"]
WEST
[/TD]
[TD="width: 85"]
[/TD]
[TD="width: 104"]
900
[/TD]
[TD="width: 40, bgcolor: transparent"][/TD]
[TD="width: 38, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 66, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[TD="width: 91, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="width: 76"]
[/TD]
[TD="width: 68"]
[/TD]
[TD="width: 112"]
WEST
[/TD]
[TD="width: 85"]
[/TD]
[TD="width: 104"]
990
[/TD]
[TD="width: 40, bgcolor: transparent"][/TD]
[TD="width: 38, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 66, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[TD="width: 91, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="width: 76"]
[/TD]
[TD="width: 68"]
[/TD]
[TD="width: 112"]
WEST
[/TD]
[TD="width: 85"]
[/TD]
[TD="width: 104"]
1,089
[/TD]
[TD="width: 40, bgcolor: transparent"][/TD]
[TD="width: 38, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 66, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[TD="width: 91, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="width: 76"]
[/TD]
[TD="width: 68"]
[/TD]
[TD="width: 112"]
WEST
[/TD]
[TD="width: 85"]
[/TD]
[TD="width: 104"]
1,198
[/TD]
[TD="width: 40, bgcolor: transparent"][/TD]
[TD="width: 38, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 66, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[TD="width: 91, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="width: 76"]
[/TD]
[TD="width: 68"]
[/TD]
[TD="width: 112"]
WEST -1
[/TD]
[TD="width: 85"]
[/TD]
[TD="width: 104"]
1,100
[/TD]
[TD="width: 40, bgcolor: transparent"][/TD]
[TD="width: 38, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 66, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[TD="width: 91, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="width: 76"]
[/TD]
[TD="width: 68"]
[/TD]
[TD="width: 112"]
WEST -1
[/TD]
[TD="width: 85"]
[/TD]
[TD="width: 104"]
1,210
[/TD]
[TD="width: 40, bgcolor: transparent"][/TD]
[TD="width: 38, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 66, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[TD="width: 91, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="width: 76"]
[/TD]
[TD="width: 68"]
[/TD]
[TD="width: 112"]
WEST -1
[/TD]
[TD="width: 85"]
[/TD]
[TD="width: 104"]
1,331
[/TD]
[TD="width: 40, bgcolor: transparent"][/TD]
[TD="width: 38, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 66, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[TD="width: 91, bgcolor: transparent"][/TD]
[/TR]
[TR]
[TD="width: 76"]
[/TD]
[TD="width: 68"]
[/TD]
[TD="width: 112"]
WEST -1
[/TD]
[TD="width: 85"]
[/TD]
[TD="width: 104"]
1,464
[/TD]
[TD="width: 40, bgcolor: transparent"][/TD]
[TD="width: 38, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 66, bgcolor: transparent"][/TD]
[TD="width: 57, bgcolor: transparent"][/TD]
[TD="width: 64, bgcolor: transparent"][/TD]
[TD="width: 91, bgcolor: transparent"][/TD]
[/TR]
</tbody>[/TABLE]