Note: The other languages of the website are Google-translated. Back to English
English English

Bagaimana cara memfilter semua sel tanggal sebelum atau sesudah hari ini di Excel?

Pada artikel ini, saya akan berbicara tentang cara memfilter semua sel tanggal yang sebelum atau sesudah hari ini di lembar kerja Excel.

Filter semua sel tanggal sebelum atau sesudah hari ini dengan fungsi Filter

Filter semua sel tanggal sebelum atau sesudah hari ini dengan kode VBA


Filter semua sel tanggal sebelum atau sesudah hari ini dengan fungsi Filter


Faktanya, fitur Filter di Excel dapat membantu Anda menyelesaikan tugas ini secepat mungkin, lakukan seperti ini:

1. Pilih kolom tanggal yang ingin Anda filter, lalu klik Data > SARING, lihat tangkapan layar:

doc filter sebelum hari ini 1

2. Kemudian klik panah drop-down, lalu pilih Filter Tanggal > Sebelum / Setelah seperti yang Anda butuhkan, lihat tangkapan layar:

doc filter sebelum hari ini 2

3. di Filter Otomatis Kustom kotak dialog, klik Pemetik tanggaldoc filter sebelum hari ini 3 tombol, dan kemudian klik Hari ini di kalender pemilih tanggal, lihat screesnhot:

doc filter sebelum hari ini 4

4. Lalu klik OK untuk menutup dialog, dan semua tanggal sebelum atau sesudah hari ini telah disaring seperti gambar berikut yang ditampilkan:

doc filter sebelum hari ini 5


Filter semua sel tanggal sebelum atau sesudah hari ini dengan kode VBA

Kode VBA berikut juga dapat membantu Anda memfilter semua tanggal sebelum atau sesudah hari ini di lembar kerja. Silakan lakukan dengan langkah-langkah di bawah ini:

1. Tahan ALT + F11 kunci untuk membuka Microsoft Visual Basic untuk Aplikasi jendela.

2. Klik Menyisipkan > Modul, dan tempel salah satu kode berikut di Modul Jendela.

Kode VBA: Filter semua sel tanggal sebelum hari ini:

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:

doc filter defore today 6

4. And then click OK button, all date cells which before or after today will be filtered out immediately.


The Best Office Productivity Tools

Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial. 60-day money back guarantee.
kte tab 201905

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!
officetab bottom
Comments (1)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
I HAVE DATA in a following format
12/11/2018 16:10
12/11/2018 16:10
12/11/2018 16:10
12/11/2018 16:10
12/11/2018 16:10
12/11/2018 16:10
12/11/2018 16:10
12/11/2018 16:10
12/11/2018 16:10
12/11/2018 16:10



and I want to filter it for TODAY - LAST 7 Days Excluding Today , That is if today is 12 Dec I want filter for 12 Dec and December[ 11,10,9,8,7,6,5] .
How to create custom filter for this in MS Excel
There are no comments posted here yet
Leave your comments
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations