Filter Today's Date with VBA -So tricky

jevi

Active Member
Joined
Apr 13, 2010
Messages
339
Office Version
  1. 2016
Platform
  1. Windows
Code:
Sub Ufa()
    x = CLng(Date)
    ActiveSheet.UsedRange.AutoFilter Field:=9, Criteria1:=">=" & x, Operator:=xlAnd, Criteria2:="<" & x + 1
End Sub

I have this macro to filter today's date is working great but is not giving me the header only the date without header...I don't know what to do :(.

Help help.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Is your header row in row 1?
 
Upvote 0
In that case rather than using Used range try specifiying the range eg
Range("A9:G100")
 
Upvote 0
Code:
Sub Ufa()    Dim LastRrow As Long
    LastRrow = Attuale.Range("A" & Rows.Count).End(xlUp).Row


x = CLng(Date)
    ActiveSheet.Range("A9:J" & LastRrow).AutoFilter Field:=9, Criteria1:=">=" & x, Operator:=xlAnd, Criteria2:="<" & x + 1
End Sub

Pluff thank you so much really you just lighted my head...I was tired and not working out trying even record a macro was not really working this filter date. Instead of a range I used the last row which workd great for me.

I tried it and works perfectly.....thank youuuuuuuuuuuuu Pluff you are just GREAT:)
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,262
Members
452,627
Latest member
KitkatToby

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