Solved Date format filter

suryu

Member
Local time
Today, 21:01
Joined
Apr 3, 2020
Messages
86
Hi, i want to filter column having date format in "dd-mmm-yy"
Column range :=E1 and autofilter field:=5
 
Code does not work? What happens?

What is actually in the cell? Text or a formatted number?
 
Are you talking about Excel VBA?
 
Hi, i want to filter column having date format in "dd-mmm-yy"
Column range :=E1 and autofilter field:=5
Use the Macro Recorder to get the basics, then amend to suit.
 
Code does not work? What happens?

What is actually in the cell? Text or a formatted number?
Its formatted number

i am trying below code which is not working

(My column name is closing date)

strDate="06-Aug-10"

With Activesheet
.AutoFilterMode= False
.Range("E1").autoFilter
.Range("E1").AutoFilter Field:=5, Citeria1:=">" & Format(strDate, "dd-mmm-yy")

End With
 
Format is just that, a format.
Search for the date as a normal date.

Macro recorder would show you that.?
 
Misspelling: Citeria1 should be Criteria1. Code works. Don't even need Format() function.
 
Misspelling: Citeria1 should be Criteria1. Code works. Don't even need Format() function.
Criteria1 is fine but still filter is not working, in column blank is there but what i want date value to be filtered.
 
Last edited:
Why are you posting a question about Excel VBA on an ACCESS forum?

All VBA is not created equal!

You should probably try a forum dedicated to MS Excel.

Linq ;0)>
 
Your date field is stored as a number in excel as it would be in Access.
You need to filter by a date value not a string.

> DateValue (strDate)
 
As Gasman suggested, this is a time to use the macro recorder and then adjust the resulting code to suit.
 
Why are you posting a question about Excel VBA on an ACCESS forum?
There is an Excel forum here? The question belongs there if that's what the issue is about, but it's not uncommon to post things in the wrong place, no?
 
I tested your code and it works for me - with or without Format() function. If you want to provide file for analysis, follow instructions at bottom of my post.
 
Why are you posting a question about Excel VBA on an ACCESS forum?

All VBA is not created equal!

You should probably try a forum dedicated to MS Excel.

Linq ;0)>
Ok thanks it was not known to me
 

Users who are viewing this thread

Back
Top Bottom