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:

[TABLE="width: 131"]
<tbody>[TR]
[TD]6/2/2018 16:32[/TD]
[/TR]
[TR]
[TD]6/10/2018 8:27[/TD]
[/TR]
[TR]
[TD](blank)[/TD]
[/TR]
[TR]
[TD](blank)[/TD]
[/TR]
[TR]
[TD](blank)[/TD]
[/TR]
[TR]
[TD](blank)[/TD]
[/TR]
[TR]
[TD](blank)[/TD]
[/TR]
[TR]
[TD](blank)[/TD]
[/TR]
[TR]
[TD](blank)[/TD]
[/TR]
[TR]
[TD](blank)[/TD]
[/TR]
[TR]
[TD](blank)[/TD]
[/TR]
[TR]
[TD]6/8/2018 23:48[/TD]
[/TR]
[TR]
[TD](blank)[/TD]
[/TR]
</tbody><colgroup><col></colgroup>[/TABLE]


Thanks!!
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
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,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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