如何在Excel中今天之前或之后過濾所有日期單元格?
在本文中,我將討論如何過濾Excel工作表中今天之前或之后的所有日期單元格。
使用過濾器功能過濾今天之前或之后的所有日期單元格
使用VBA代碼過濾今天之前或之后的所有日期單元格
使用過濾器功能過濾今天之前或之后的所有日期單元格
驚人的! 在 Excel 中使用高效的選項(xiàng)卡,如 Chrome、Firefox 和 Safari!
每天節(jié)省50%的時(shí)間,并減少數(shù)千次鼠標(biāo)單擊!
實(shí)際上,Excel中的篩選器功能可以幫助您盡快解決此任務(wù),請執(zhí)行以下操作:
1。 選擇您要篩選的日期列,然后單擊 Data > 篩選器,請參見屏幕截圖:
2。 然后單擊下拉箭頭,然后選擇 日期過濾器 > 之前 / 后 根據(jù)需要,請參見屏幕截圖:

3。 在 自定義自動篩選 對話框,單擊 日期選擇器 按鈕,然后單擊 的旅程 日期選擇器日歷中的按鈕,請參見screesnhot:
4。 然后點(diǎn)擊 OK 關(guān)閉對話框,并過濾掉今天之前或之后的所有日期,如下所示的屏幕截圖:
使用VBA代碼過濾今天之前或之后的所有日期單元格
以下VBA代碼還可以幫助您過濾工作表中當(dāng)天之前或之后的所有日期。 請執(zhí)行以下步驟:
1。 按住 ALT + F11 鍵打開 Microsoft Visual Basic應(yīng)用程序 窗口。
2。 點(diǎn)擊 插頁 > 模塊,然后將以下代碼之一粘貼到 模塊 窗口。
VBA代碼:過濾今天之前的所有日期單元:
Sub FilterDateBeforeToday()
Dim xLastRow As Long
Dim xRg As Range
On Error Resume Next
Set xRg = Application.InputBox("Please select filtered column:", "KuTools for Excel", Selection.Address, , , , , 8)
If xRg Is Nothing Then Exit Sub
Application.ScreenUpdating = False
ActiveSheet.AutoFilterMode = False
If xRg.Count = 1 Then Set xRg = xRg.CurrentRegion
xRg.AutoFilter 1, "<" & CDbl(Date)
Application.ScreenUpdating = True
End Sub
VBA code: Filter all date cells after today:
Sub FilterDateBeforeToday()
Dim xLastRow As Long
Dim xRg As Range
On Error Resume Next
Set xRg = Application.InputBox("Please select filtered column:", "KuTools for Excel", Selection.Address, , , , , 8)
If xRg Is Nothing Then Exit Sub
Application.ScreenUpdating = False
ActiveSheet.AutoFilterMode = False
If xRg.Count = 1 Then Set xRg = xRg.CurrentRegion
xRg.AutoFilter 1, ">" & CDbl(Date)
Application.ScreenUpdating = True
End Sub
3. After copying and pasting one of the above codes, then press F5 key to run this code, and a prompt box will pop out to remind you selected the date column that you want to filter, see screenshot:
4. And then click OK button, all date cells which before or after today will be filtered out immediately.
Best Office Productivity Tools
Transform Hours into Minutes with Kutools for Excel!
Ready to supercharge your Excel tasks? Harness the power of Kutools for Excel - your ultimate time-saving tool. Streamline intricate tasks and glide through your data like a pro. Experience Excel at lightning speed!
Why You Need Kutools for Excel
??? Over 300 Powerful Features: Kutools is packed with more than 300 advanced features, simplifying your work in over 1500 scenarios.
?? Superior Data Processing: Merge cells, remove duplicates, and perform advanced data conversions – all without breaking a sweat!
?? Efficient Batch Operations: Why put in extra effort when you can work smart? Import, export, combine, and tweak data in bulk with ease.
?? Customizable Charts and Reports: Access a broad variety of additional charts and generate insightful reports that tell a story.
??? Powerful Navigation Pane: Gain an advantage with the robust Column Manager, Worksheet Manager, and Custom Favorites.
?? Seven Types of Drop-down Lists: Make data entry a breeze with drop-down lists of various features and types.
?? User-Friendly: A breeze for beginners and a powerful tool for experts.
Download Now and Soar Through Time with Excel!
Read More... Free Download... Purchase...
Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier
Enable tabbed editing and reading in
Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
Open and create multiple documents in new tabs of the same window, rather than in new windows.
Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
Read More... Free Download... Purchase...