如何在Excel中今天之前或之后过滤所有日期单元格?

网友投稿 247 2023-12-27

如何在Excel中今天之前或之后过滤所有日期单元格?

在本文中,我将讨论如何过滤Excel工作表中今天之前或之后的所有日期单元格。

使用过滤器功能过滤今天之前或之后的所有日期单元格

使用VBA代码过滤今天之前或之后的所有日期单元格

使用过滤器功能过滤今天之前或之后的所有日期单元格
惊人的! 在 Excel 中使用高效的选项卡,如 Chrome、Firefox 和 Safari! 每天节省50%的时间,并减少数千次鼠标单击!

实际上,Excel中的筛选器功能可以帮助您尽快解决此任务,请执行以下操作:

1。 选择您要筛选的日期列,然后单击 Data > 筛选器,请参见屏幕截图:

2。 然后单击下拉箭头,然后选择 日期过滤器 > 之前 / 根据需要,请参见屏幕截图:

3。 在 自定义自动筛选 对话框,单击 日期选择器 按钮,然后单击 的旅程 日期选择器日历中的按钮,请参见screesnhot:

4。 然后点击 OK 关闭对话框,并过滤掉今天之前或之后的所有日期,如下所示的屏幕截图:

使用VBA代码过滤今天之前或之后的所有日期单元格

如何在Excel中今天之前或之后过滤所有日期单元格?

以下VBA代码还可以帮助您过滤工作表中当天之前或之后的所有日期。 请执行以下步骤:

1。 按住 ALT + F11 键打开 Microsoft Visual Basic应用程序 窗口。

2。 点击 插页 > 模块,然后将以下代码之一粘贴到 模块 窗口。

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
Copy
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...

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:如何在Excel中使用换行符或回车符过滤所有单元格?
下一篇:如何从Excel中的合并单元格过滤所有相关数据?
相关文章