VBA date filter,how to add one more filter

2avrham

Board Regular
Joined
May 12, 2014
Messages
104
Office Version
  1. 365
Hi,

I have the next VBA code that filtered between two dates.
I wander how can I modify it to bring me also the "(blank)" cells that I have ( I need them too).

Sub filter_24()
Dim StartDate As Date, EndDate As Date
StartDate = DateAdd("h", "-16", Date)
EndDate = DateAdd("h", "8", Date)
Range("A5:T5").AutoFilter Field:=17, _
Criteria1:=">=" & StartDate, _
Operator:=xlAnd, _
Criteria2:="<=" & EndDate


any idea how to do this?

Few rows from my column table:

6/2/2018 16:32
6/10/2018 8:27
(blank)
(blank)
(blank)
(blank)
(blank)
(blank)
(blank)
(blank)
(blank)
6/8/2018 23:48
(blank)

<tbody>
</tbody><colgroup><col></colgroup>


Thanks!!
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Hi there. You cant directly have more than 2 filters set. However, if you can add an extra column to your table, you could put in a formula like this (I assumed your date field is in column Q):
=OR(Q5="",AND(Q5>=NOW()-16/24,Q5<=NOW()+8/24)) and filter on this column for true.
 
Upvote 0

Forum statistics

Threads
1,215,019
Messages
6,122,707
Members
449,093
Latest member
Mnur

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