Advanced Filter using a date as the criteria

jaded62

New Member
Joined
Oct 23, 2023
Messages
6
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I am trying to do a simple Advanced Filter that filters for one date.

The search date is in the format of dd/mm/yyyy as are all of the dates in the data range.

Running the code below returns all dates, not just the date I'm filtering for.

I have tried formating the data and search date to mm/dd/yyyy, yyyy/dd/mm, and as a serial number. All formats return all dates.

Guidance would be greatly appreciated!

Cheers.

VBA Code:
Set wsData = wsTimesheet_Data 'Sets a reference to the data WS.
   Set wsSO = wsSAP_Operations 'Sets a reference to the SAP Ops WS.
   Set RangeResStart = wsSAP_Operations.Range("A12") 'Sets a reference to the cell A12 in the SAP Operations WS.

   Set RangeTrans = wsData.Range("TS_Data") 'Selects all the date data by Setting the range to the date colum of the data WS.
   
   Application.ScreenUpdating = False
      
   RangeResStart.CurrentRegion.ClearContents 'Clear any existing data from the search result.
        
  'Runs the advanced filter using the above criteria and copies (using the Filtercopy action) the outcome to the SAP Ops tab.
  
  RangeTrans.AdvancedFilter _
        Action:=xlFilterCopy, _
        CriteriaRange:=wsSO.Range("SAP_Date1"), _
        CopyToRange:=RangeResStart, _
        Unique:=False
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
I should add too that setting Unique to True makes no difference.
 
Upvote 0
What is the range of SAP_Date1 and what exactly is in there?
 
Upvote 0
1) Does TS_Data include the heading row of the data to be filtered ?
If not expand the range to include the heading.
2) Does SAP_Date1 have the exact same heading as TS_Data (the column for the filter) in the first row and the date in the 2nd row ?
 
Upvote 0
Solution
Headers? Of course not! In my rush to finish this before the xmas break I forgot all about that requirement.

Thanks!
 
Upvote 0

Forum statistics

Threads
1,224,817
Messages
6,181,149
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