跳到主要内容

如何在Excel中的两个特定日期之间过滤日期?

有时您可能只想在Excel中的两个特定日期之间过滤数据或记录。 例如,您要在Excel中同时显示9年1月2012日至11年30月2012日之间的销售记录,并隐藏其他记录。 本文重点介绍在Excel中轻松地在两个特定日期之间筛选日期的方法。

使用筛选器命令在两个特定日期之间筛选日期
使用VBA代码在两个特定日期之间过滤日期
使用 Kutools for Excel 选择两个特定日期之间的所有日期


使用筛选器命令在两个特定日期之间筛选日期

假设您有以下报告,现在想在9年1月2012日至11年30月2012日之间过滤项目,以便快速汇总一些信息。 查看屏幕截图:

文档过滤日期-1 -2 文档过滤日期-2

Microsoft Excel的 筛选器 该命令支持使用以下步骤过滤两个日期之间的所有日期:

:选择日期列,在这种情况下选择列C。 然后点击 时间 > 筛选器,请参见屏幕截图:

文档过滤日期-3

:单击箭头按钮 除了列C的标题。然后将鼠标移到 日期过滤器,并选择 之间 右侧列表中的项目,请参见以下屏幕截图:

文档过滤日期-4

:在弹出 自定义自动筛选 对话框中,指定您要过滤的两个日期。 请参阅以下步骤:

文档过滤日期-5

:点击 OK。 现在,它过滤两个特定日期之间的“日期”列,并隐藏其他记录,如以下屏幕快照所示:

文档过滤日期-6


使用VBA代码在两个特定日期之间过滤日期

以下简短的VBA代码也可以帮助您过滤两个特定日期之间的日期,请按照以下步骤操作:

:在空白单元格中输入两个特定日期。 在这种情况下,我在单元格E9中输入开始日期1/2012/1,在单元格E11中输入结束日期30/2012/2。

文档过滤日期-7

:然后按住 ALT + F11 键,然后打开 Microsoft Visual Basic应用程序 窗口。

:点击 插页 > 模块,然后将以下代码粘贴到“模块窗口”中。

Public Sub MyFilter()
    Dim lngStart As Long, lngEnd As Long
    lngStart = Range("E1").Value 'assume this is the start date
    lngEnd = Range("E2").Value 'assume this is the end date
    Range("C1:C13").AutoFilter field:=1, _
        Criteria1:=">=" & lngStart, _
        Operator:=xlAnd, _
        Criteria2:="<=" & lngEnd
End Sub

请注意:

  • 在上面的代码中, lngStart = Range(“ E1”), E1 是工作表中的开始日期,并且 lngEnd = Range(“ E2”), E2 是您指定的结束日期。
  • 范围(“ C1:C13”), 范围 C1:C13 是您要过滤的日期列。
  • 以上所有代码都是变量,您可以根据需要进行更改。

:然后按 F5 键以运行此代码,并且已过滤9年1月2012日至11年30月2012日之间的记录。


使用 Kutools for Excel 选择两个特定日期之间的所有日期

在本节中,我们建议您 选择特定的单元格 实用程序 Kutools for Excel。 使用此实用程序,您可以轻松地选择特定范围内两个特定日期之间的所有行,然后将这些行移动或复制到工作簿中的其他位置。

申请前 Kutools for Excel首先下载并安装.

1:选择您要按两个日期过滤的范围, 依次 库工具 > 选择 > 选择特定的单元格...

2: 在里面 选择特定的单元格 对话框中,指定如下设置

  • 1)。 选择 整行 在选项 选择类型 部分。
  • 2)。 在里面 特定类型 部分,请先选择 大于或等于 小于或等于 在两个下拉列表中。 然后在以下文本框中输入开始日期和结束日期。
  • 3)。 点击 OK 按钮。 看截图:

文档过滤日期-9

现在,已选择所有符合条件的行。 然后,您可以根据需要将选定的行复制并粘贴到所需的范围。

  如果您想免费试用(30天)此实用程序, 请点击下载,然后按照上述步骤进行操作。


使用 Kutools for Excel 过滤两个特定日期之间的所有日期


相关文章:

最佳办公生产力工具

🤖 Kutools 人工智能助手:基于以下内容彻底改变数据分析: 智能执行   |  生成代码  |  创建自定义公式  |  分析数据并生成图表  |  调用 Kutools 函数...
热门特色: 查找、突出显示或识别重复项   |  删除空白行   |  合并列或单元格而不丢失数据   |   不使用公式进行四舍五入 ...
超级查询: 多条件VLookup    多值VLookup  |   跨多个工作表的 VLookup   |   模糊查询 ....
高级下拉列表: 快速创建下拉列表   |  依赖下拉列表   |  多选下拉列表 ....
列管理器: 添加特定数量的列  |  移动列  |  切换隐藏列的可见性状态  |  比较范围和列 ...
特色功能: 网格焦点   |  设计图   |   大方程式酒吧    工作簿和工作表管理器   |  资源库 (自动文本)   |  日期选择器   |  合并工作表   |  加密/解密单元格    按列表发送电子邮件   |  超级筛选   |   特殊过滤器 (过滤粗体/斜体/删除线...)...
前 15 个工具集12 文本 工具 (添加文本, 删除字符,...)   |   50+ 图表 类型 (甘特图,...)   |   40+ 实用 公式 (根据生日计算年龄,...)   |   19 插入 工具 (插入二维码, 从路径插入图片,...)   |   12 转化 工具 (小写金额转大写, 货币兑换,...)   |   7 合并与拆分 工具 (高级组合行, 分裂细胞,...)   |   ... 和更多

使用 Kutools for Excel 增强您的 Excel 技能,体验前所未有的效率。 Kutools for Excel 提供了 300 多种高级功能来提高生产力并节省时间。  单击此处获取您最需要的功能...

产品描述


Office Tab 为 Office 带来选项卡式界面,让您的工作更加轻松

  • 在Word,Excel,PowerPoint中启用选项卡式编辑和阅读,发布者,Access,Visio和Project。
  • 在同一窗口的新选项卡中而不是在新窗口中打开并创建多个文档。
  • 每天将您的工作效率提高50%,并减少数百次鼠标单击!
Comments (10)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
really cool - thank you
This comment was minimized by the moderator on the site
Date on which performed
19/04/2019 - 19/04/2019
08/05/2019 - 08/05/2019
14/05/2019 - 21/05/2019

15/05/2019 - 15/05/2019
15/05/2019 - 29/05/2019
21/05/2019 - 30/05/2019
22/05/2019 - 12/06/2019
22/05/2019 - 27/05/2019
22/05/2019 - 19/06/2019
24/05/2019 - 06/06/2019
24/05/2019 - 24/05/2019
27/05/2019 - 03/06/2019
27/05/2019 - 27/05/2019
27/05/2019 - 27/05/2019
28/05/2019 - 29/05/2019
30/05/2019 - 30/05/2019
30/05/2019 - 30/05/2019
31/05/2019 - 22/06/2019


which filter do i need to use to filter it with the end date. now after 08/05/2019 the next task was completed by 21/05/2019. i need to arrange in date wise when the task was closed. can anyone suggest me please.
This comment was minimized by the moderator on the site
Hello, Is it possible to get the results to filter to another tab in the worksheet?
This comment was minimized by the moderator on the site
Hi guys, is it possible to creat a loop for the sample "Filter dates between two specific dates with VBA code"? Because i have a lot of dates and not just one as shown here. Thank you!
This comment was minimized by the moderator on the site
excellent, thank you so much
This comment was minimized by the moderator on the site
YOU SHOULD FIRST OF ALL CHANGE THE DATE COLUMN TO DATE DATATYPE.
This comment was minimized by the moderator on the site
thank you this comment is very useful :D
This comment was minimized by the moderator on the site
Hi For Step 2 Instead of the "Date Filter" I see "Text Filter" All of the cells in the column are dates and they are formatted as MM/DD/YYYY I am not sure how to format the Text Filter to be a Date Filter Any Advice? Thank You
This comment was minimized by the moderator on the site
thank you, this is very helpful
This comment was minimized by the moderator on the site
Thank you very much for providing this valuable article
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations