Advance Filter Macro

Negi1984

Board Regular
Joined
May 6, 2011
Messages
199
Hi All,

I have data in below format :-
Now I want to add a filter as below mentioned criteria :-

1) Picklisted : Should be New
2) 410(A) : Should remove latest 6 dates from filter
3) GR1 : Should be False
4) GR01 : Should be select all numbers & numbers where 2 numbers mentioned with text Rej.

I tried by myself with without macro with advance filter , but unable to found any solution, how to filter out latest 6 dates from filter. Please assist.
[TABLE="width: 378"]
<tbody>[TR]
[TD]State[/TD]
[TD] Program[/TD]
[TD]Picklisted[/TD]
[TD]410 (A)[/TD]
[TD]GRO1[/TD]
[TD]GR1[/TD]
[/TR]
[TR]
[TD]0[/TD]
[TD]A[/TD]
[TD]New[/TD]
[TD]7-Aug-13[/TD]
[TD]2334[/TD]
[TD]FALSE[/TD]
[/TR]
[TR]
[TD]NSW[/TD]
[TD]B[/TD]
[TD]Old site[/TD]
[TD]24-Jul-13[/TD]
[TD]2442[/TD]
[TD]FALSE[/TD]
[/TR]
[TR]
[TD]NSW[/TD]
[TD]C[/TD]
[TD]New[/TD]
[TD]21-Oct-15[/TD]
[TD]3444[/TD]
[TD]TRUE[/TD]
[/TR]
[TR]
[TD]NSW[/TD]
[TD]D[/TD]
[TD]New[/TD]
[TD]15-Jan-15[/TD]
[TD]2345[/TD]
[TD]FALSE[/TD]
[/TR]
[TR]
[TD]NSW[/TD]
[TD]E[/TD]
[TD]Old site[/TD]
[TD]3-Sep-15[/TD]
[TD]5223[/TD]
[TD]FALSE[/TD]
[/TR]
[TR]
[TD]0[/TD]
[TD]G[/TD]
[TD]New[/TD]
[TD]11-Jun-14[/TD]
[TD]71,74 Rej[/TD]
[TD]FALSE[/TD]
[/TR]
[TR]
[TD]QLD[/TD]
[TD]D[/TD]
[TD]Old site[/TD]
[TD]29-Aug-13[/TD]
[TD]4555[/TD]
[TD]TRUE[/TD]
[/TR]
[TR]
[TD]QLD[/TD]
[TD]S[/TD]
[TD]New[/TD]
[TD]20-Sep-13[/TD]
[TD]31,74, Rej[/TD]
[TD]FALSE[/TD]
[/TR]
[TR]
[TD]QLD[/TD]
[TD]SS[/TD]
[TD]Old site[/TD]
[TD]15-Jul-13[/TD]
[TD]7470[/TD]
[TD]FALSE[/TD]
[/TR]
[TR]
[TD]QLD[/TD]
[TD]ER[/TD]
[TD]Old site[/TD]
[TD]16-Jul-13[/TD]
[TD]7470[/TD]
[TD]FALSE[/TD]
[/TR]
[TR]
[TD]WA[/TD]
[TD]4[/TD]
[TD]New[/TD]
[TD]17-Sep-13[/TD]
[TD]74,Rej[/TD]
[TD]FALSE[/TD]
[/TR]
[TR]
[TD]WA[/TD]
[TD]56[/TD]
[TD]Old site[/TD]
[TD]12-Aug-13[/TD]
[TD]7470[/TD]
[TD]TRUE[/TD]
[/TR]
</tbody><colgroup><col><col><col><col><col><col></colgroup>[/TABLE]
 
Rajender,

Delete the previous version of the function EvalCell and paste this new version

Code:
Function EvalCell(r As Range)
    Dim spl As Variant, i As Long, lCounter As Long
    
    If Application.IsNumber(r.Value) Then
        EvalCell = "Y"
    ElseIf InStr(1, r.Value, "Rejected", vbTextCompare) > 0 Then
            spl = Split(Application.Trim(Replace(Replace(Replace(r, "-", " "), ",", " "), "Rejected", "")))
            For i = LBound(spl) To UBound(spl)
                If IsNumeric(spl(i)) Then lCounter = lCounter + 1
            Next i
            If lCounter > 1 Then
                EvalCell = "Y"
            Else
                EvalCell = "N"
            End If
    Else
            EvalCell = "N"
    End If
End Function

Hope this works :pray:

M.
 
Upvote 0

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Use the code in post 19 to run the macro AdvFilter with the function EvalCell above (new version)

M.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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