![]() |
Advanced autofilter not working in macro
I am using the follwoing code to filter data greater than certain date. But
unfortunately all data gets hide when I run the macro. However when I open and close the autofilet after Macro has run, proper values are visible. please help me out... Date = Cells(erow - 49, 4) Sheets("data").Select Range("a6").Select Selection.AutoFilter Range("O6").Select Selection.AutoFilter Field:=15, Criteria1:="=" & Date |
Advanced autofilter not working in macro
Try
Selection.AutoFilter Field:=15, Criteria1:="=" & Date, Criteria2:= "<=" & Date -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Nirmal" wrote in message ... I am using the follwoing code to filter data greater than certain date. But unfortunately all data gets hide when I run the macro. However when I open and close the autofilet after Macro has run, proper values are visible. please help me out... Date = Cells(erow - 49, 4) Sheets("data").Select Range("a6").Select Selection.AutoFilter Range("O6").Select Selection.AutoFilter Field:=15, Criteria1:="=" & Date |
Advanced autofilter not working in macro
Sometimes converting the date to a long will help:
Selection.AutoFilter Field:=15, Criteria1:="=" & clng(Date) Sometimes formatting the date to match the existing format of what's in the other cells in the field will help: Selection.AutoFilter Field:=15, Criteria1:="=" & format(Date,"mm/dd/yyyy") (change that format to match your data, though) Nirmal wrote: I am using the follwoing code to filter data greater than certain date. But unfortunately all data gets hide when I run the macro. However when I open and close the autofilet after Macro has run, proper values are visible. please help me out... Date = Cells(erow - 49, 4) Sheets("data").Select Range("a6").Select Selection.AutoFilter Range("O6").Select Selection.AutoFilter Field:=15, Criteria1:="=" & Date -- Dave Peterson |
Advanced autofilter not working in macro
"Dave Peterson" wrote in message ... Sometimes formatting the date to match the existing format of what's in the other cells in the field will help: Selection.AutoFilter Field:=15, Criteria1:="=" & format(Date,"mm/dd/yyyy") Get the cell format in this imstance With Selection .AutoFilter Field:=15, Criteria1:="=" & Format(Date, .Cells(2, 15).NumberFormat) End With |
All times are GMT +1. The time now is 04:04 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com