Filter all rows where date is between today and 30 days from today?

Human_doing

Board Regular
Joined
Feb 16, 2011
Messages
137
Hi all,

Can someone please help with how to filter a worksheet so only rows where the date field shows a date between today's date and 30 days from today shows up? If anyone can explain the general principle then I can follow that whilst recording a macro and put it in to the overall VBA, I can't see how 'filter' or 'autofilter' on Excel 2003 can do this and haven't found the right VBA on this forum to produce the right result,

Any help much appreciated
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
You can use a Custom AutoFilter. VBA example for column A on Sheet1:

Code:
Sub Test()
    Dim Sh As Worksheet
    Set Sh = Worksheets("Sheet1")
    With Sh.Range("A1").CurrentRegion
        .AutoFilter
        .AutoFilter Field:=1, Criteria1:=">=" & CLng(Date), Operator:=xlAnd, Criteria2:="<=" & CLng(Date + 30)
    End With
End Sub
 
Upvote 0
Thanks for your quick reply.

Could you please tell me what the exact code should be if the date field is column C, headed 'Review Date'?

Thanks
 
Upvote 0
I have a very similar one, but I just cannot use the same...
I have several file sources (all around 2-300.000 lines) the same format each, in column Z the date what I need. My pivot with the macro is in a separate file. In my pivot I want to update the source without removing the other filters and filter always on the last 3 months only. And also on one sheet I have several pivot as well.
Just cannot make it...
Any idea would be appreciated!
 
Upvote 0

Forum statistics

Threads
1,224,613
Messages
6,179,903
Members
452,948
Latest member
Dupuhini

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