Filter time on one column between 05:00 AM to 00:00 AM (exclude time between 5AM-00AM)

Gwhaou

Board Regular
Joined
May 10, 2022
Messages
78
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Hi,

I need some help I know, it's possible to use macro to filter data from one column actualy I use this type of code to filter one specific data from one column

VBA Code:
Sheets("Sheet_1").Range("A1").AutoFilter Field:=1, Criteria1:="05:00"

With this code I can took all the data with the time 5 AM from the column, And It works. But in my data sheet on this column i have a bunch of time data. I want a macro to filter only data between 05:00 AM to 00:00 AM. Is possible to tell that with AutoFilter ?
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Maybe:
VBA Code:
Sheets("Sheet_1").Range("A1").AutoFilter Field:=1, Criteria1:=">=" & TimeValue("05:00"
This should show all the times between 5:00 and 23:59:59
 
Upvote 0
Solution
Maybe:
VBA Code:
Sheets("Sheet_1").Range("A1").AutoFilter Field:=1, Criteria1:=">=" & TimeValue("05:00"
This should show all the times between 5:00 and 23:59:59
Thanks it works perfectly 👌, got a last question, just to understand the code.
If I want time between 5 AM an 22:59:59 PM how would you write that ?
 
Upvote 0
VBA Code:
    Sheets("Sheet_1").Range("A1").AutoFilter Field:=1, Criteria1:=">=" & TimeValue("05:00"), _
                    Operator:=xlAnd, Criteria2:="<" & TimeValue("23:00")
 
Upvote 0

Forum statistics

Threads
1,215,389
Messages
6,124,662
Members
449,178
Latest member
Emilou

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top