ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Filter date in macro (https://www.excelbanter.com/excel-discussion-misc-queries/155583-filter-date-macro.html)

Dolphinv4

Filter date in macro
 
Hi,

i set up a macro below to filter out a column (dates) that are more than
cell F2, where cell F2 is also a date. But it just doesn't work. Why? Thanks!

Sub Filter_BS()

Selection.AutoFilter Field:=7, Criteria1:="" & Range("f2"),
Operator:=xlAnd

End Sub

Val

Dave Peterson

Filter date in macro
 
I'd try:

Selection.AutoFilter Field:=7, _
Criteria1:="" & format(Range("f2").value,"mm/dd/yyyy")

But match the numberformat of the dates in that field.

Dolphinv4 wrote:

Hi,

i set up a macro below to filter out a column (dates) that are more than
cell F2, where cell F2 is also a date. But it just doesn't work. Why? Thanks!

Sub Filter_BS()

Selection.AutoFilter Field:=7, Criteria1:="" & Range("f2"),
Operator:=xlAnd

End Sub

Val


--

Dave Peterson


All times are GMT +1. The time now is 02:16 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com