Negi1984

Board Regular
Joined
May 6, 2011
Messages
198
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.
State ProgramPicklisted410 (A)GRO1GR1
0ANew7-Aug-132334FALSE
NSWBOld site24-Jul-132442FALSE
NSWCNew21-Oct-153444TRUE
NSWDNew15-Jan-152345FALSE
NSWEOld site3-Sep-155223FALSE
0GNew11-Jun-1471,74 RejFALSE
QLDDOld site29-Aug-134555TRUE
QLDSNew20-Sep-1331,74, RejFALSE
QLDSSOld site15-Jul-137470FALSE
QLDEROld site16-Jul-137470FALSE
WA4New17-Sep-1374,RejFALSE
WA56Old site12-Aug-137470TRUE

<tbody>
</tbody><colgroup><col><col><col><col><col><col></colgroup>
 
See if this array formula works with your data

K2
=LARGE(IF(ISNUMBER(D2:D25),IF(MATCH(D2:D25,D2:D25,0)=ROW(D2:D25)-ROW(D2)+1,D2:D25)),6)
confirmed with Ctrl+Shift+Enter, not just Enter

M.
 
Upvote 0

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Hi Marcelo,

Now the error not coming even if any alphabetic field in Date column. But the output date which is showing here is incorrect. it should look for the largest 6th in column Picklisted under filter "New" Only. current its showing output of 6th largest values considering "New" & "Old site" both.

Note : It should also consider duplicate dates as well.

Regards,
Rajender
 
Last edited:
Upvote 0
Try this new version

=LARGE(IF(C2:C25="New",IF(ISNUMBER(D2:D25),IF(MATCH(D2:D25,D2:D25,0)=ROW(D2:D25)-ROW(D2)+1,D2:D25))),6)
Ctrl+Shift+Enter

M.
 
Upvote 0
The formula in post 13 needs an adjustment

Correction
=LARGE(IF(C2:C25="New",IF(ISNUMBER(D2:D25),IF(MATCH(IF(C2:C25="New",D2:D25),IF(C2:C25="New",D2:D25),0)=ROW(D2:D25)-ROW(D2)+1,D2:D25))),6)
Ctrl+Shift+Enter

M.
 
Upvote 0
Hi Marcelo,

I have checked the data in provided file everything was working fine, but once I pasted the final original values in this test file it is not showing any output in "Output sheet".
Could you please tell me what I am doing wrong ?

I have attached once again the original file.

https://1drv.ms/x/s!Ap80Ku6M2Tw5gTTW7JU9KBZEpyg8

Regards,
Rajender
 
Upvote 0
Are you using Excel on-line or a desktop version?
I've no experience with Excel on-line.

M.
 
Upvote 0
Hi Marcelo,

I am using Desktop version. you can download the file from link provided.

Regards,
Rajender
 
Upvote 0
Rajender,

Problems with your data
1. You told me that the criteria in column C should be "New", but in fact in your sheet the values are "New Site"
I had to correct the formula to use the proper value.

2. There are no numbers in column E (GRO1), only text
To fix it:
Select column E; go to Data > Text to columns; in the first step click in Finish
This should convert the "numbers" to real numbers

After this corrections, try this macro - it worked perfectly for me

Code:
Sub AdvFilter()
    Dim LR As Long
    
    With Sheets("Data")
        'Get lastrow with data
        LR = .Cells(.Rows.Count, "A").End(xlUp).Row
       'Prepare criteria in I1:I2
       .Range("I1") = ""
       .Range("I2").Formula = "=AND(C2=""New Site"",$K$2>D2,F2=FALSE,EvalCell(E2)=""Y"")"
       'Apply Advanced Filter
       .Range("A1:G" & LR).AdvancedFilter Action:=xlFilterCopy, _
            CriteriaRange:=.Range("I1:I2"), CopyToRange:=Sheets("Output").Range("C3:H3"), Unique:=False
    End With
End Sub

M.
 
Upvote 0
Remark: the macro above assumes that the headers (Data!A1:F1) do already exist in the range C3:H3 of Output. If they do not exist, try this macro (more robust):

Code:
Sub AdvFilter()
    Dim LR As Long
    
    With Sheets("Data")
        'Get lastrow with data
        LR = .Cells(.Rows.Count, "A").End(xlUp).Row
       'Prepare criteria in I1:I2
       .Range("I1") = ""
       .Range("I2").Formula = "=AND(C2=""New Site"",$K$2>D2,F2=FALSE,EvalCell(E2)=""Y"")"
       'Prepare headers in sheet output
       Sheets("Output").Range("C3:H3").Value = .Range("A1:F1").Value
       'Apply Advanced Filter
       .Range("A1:G" & LR).AdvancedFilter Action:=xlFilterCopy, _
            CriteriaRange:=.Range("I1:I2"), CopyToRange:=Sheets("Output").Range("C3:H3"), Unique:=False
    End With
End Sub

M.
 
Upvote 0
Hi Marcelo,

Well noted your point, I have changed all the text numbers to numbers by text to column. but still there is a gap in output.
In output below result also showing :-
74702954-rejected
74704165-REJECTED
74703441- GRO REJECTED
74703964-REJECTED

I only need data with Rejected text only if numbers are double in it like 74703964 ,74703964 REJECTED or 74703964 ,74703964 -REJECTED.

Could you please guide further.

Regards,
Rajender

<tbody>
</tbody><colgroup><col></colgroup>
 
Upvote 0

Forum statistics

Threads
1,215,275
Messages
6,124,002
Members
449,137
Latest member
abdahsankhan

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