跳到主要內容

如何在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的 篩選 該命令支持使用以下步驟過濾兩個日期之間的所有日期:

步驟 1:選擇日期列,在這種情況下選擇列C。 然後點擊 數據 > 篩選,請參見屏幕截圖:

文檔過濾日期-3

步驟 2:單擊箭頭按鈕 除了列C的標題。然後將鼠標移到 日期過濾器,並選擇 之間 右側列表中的項目,請參見以下屏幕截圖:

文檔過濾日期-4

步驟 3:在彈出 自定義自動篩選 對話框中,指定您要過濾的兩個日期。 請參閱以下步驟:

文檔過濾日期-5

步驟 4:點擊 OK。 現在,它過濾兩個特定日期之間的“日期”列,並隱藏其他記錄,如以下屏幕快照所示:

文檔過濾日期-6


使用VBA代碼在兩個特定日期之間過濾日期

以下簡短的VBA代碼也可以幫助您過濾兩個特定日期之間的日期,請執行以下操作:

步驟 1:在空白單元格中輸入兩個特定日期。 在這種情況下,我在單元格E9中輸入開始日期1/2012/1,在單元格E11中輸入結束日期30/2012/2。

文檔過濾日期-7

步驟 2:然後按住 ALT + F11 鍵,然後打開 Microsoft Visual Basic for Applications 窗口。

步驟 3:點擊 插入 > 模塊,然後將以下代碼粘貼到“模塊窗口”中。

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 是您要過濾的日期列。
  • 以上所有代碼都是變量,您可以根據需要進行更改。

步驟 4:然後按 F5 鍵以運行此代碼,並且已過濾9年1月2012日至11年30月2012日之間的記錄。


使用Kutools for Excel選擇兩個特定日期之間的所有日期

在本節中,我們建議您 選擇特定的單元格 的效用 Excel的Kutools。 使用此實用程序,您可以輕鬆地選擇特定範圍內兩個特定日期之間的所有行,然後將這些行移動或複製到工作簿中的其他位置。

申請前 Excel的Kutools首先下載並安裝.

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選項卡為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