Advanced Filter not filtering

Kevin0427

Board Regular
Joined
Mar 31, 2016
Messages
69
It is probably a dumb mistake but I am not seeing it. All this code runs all the way through but does not filter the results.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim DataRange As Range
Dim FilterRange As Range
Dim DestinationRange As Range
Set DataRange = DataSheet.Range("A1").CurrentRegion
Set FilterRange = DinD.Range("C4:C6")
Set DestinationRange = DinD.Range("C37").CurrentRegion
If Target.Address = "$C$5" Then
    
    Application.EnableEvents = False
    DestinationRange.Offset(1).ClearContents
    DataRange.AdvancedFilter xlFilterCopy, FilterRange, DestinationRange
    Application.EnableEvents = True
    
End If
End Sub
 
Can you post a link to a shared site with a simple file?

Dates are a bit tricky. You will likely need ">=dateasnumber" sort of thing.

As coded, they would need to change C6 and then C5 to get the range criterion. I would probably use other cells that they update and if either of those change, it would fire the event with the criterion fields set by the Change event.
 
Last edited:
Upvote 0

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Can you post a link to a shared site with a simple file?

Dates are a bit tricky. You will likely need ">dateasnumber" sort of thing.

As coded, they would need to change C6 and then C5 to get the range criterion. I would probably use other cells that they update and if either of those were change, it would fire the event with the criterion fields set by the Change event.

I realize that. I was jut trying to get it to work before adding another layer. I have since changed the IF to include C6 too.
 
Upvote 0
To filter between values they must be on the line, so you need the header in C4 & D4 & then the criteria in C5 & D5
 
Upvote 0
To filter between values they must be on the line, so you need the header in C4 & D4 & then the criteria in C5 & D5

oops. hold on wait. The between is working on two lines. What is not working is when only one date is entered. ie >=8/1/2019 but no end date is entered.

Do I just need to hardcode in a date if one is blank? Not a very pretty solution.
 
Last edited:
Upvote 0
Putting them in C5 & D5 works for me if D5 is blank.
NO, do not merge cells.

So same header in both columns. Start and End Date on same row. Filters all of these choices:

1. > 8/1/019; and
2. <8/1/2019; and
3.>8/1/2019 and <8/30/2019
 
Upvote 0
Are you saying it's now working?
 
Upvote 0
Are you saying it's now working?

Sorry. I was out the rest of the day. No it is not working. I tested your suggestion today. If I put in a start date and no end date or an end date with no start date it does not work. Still looking for a solution. In the meantime I have hardcoded it to add the missing date if it is blank.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,885
Messages
6,122,085
Members
449,064
Latest member
MattDRT

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