Displaying date in filter criteria

R

Robert Mark Bram

Hi All,

I am using the magnificent FilterCriteria tip as per
http://j-walk.com/ss/excel/usertips/tip044.htm
to display the filter criteria being used in AutoFilters.

A question was asked on my blog about displaying the filter criteria
as a date - if it is a date.
http://robertmarkbramprogrammer.blo...ying-autofilter-criteria.html#comment-5150203

I.e. if I were to apply a custom filter: "is less than 15/01/2009",
this is displayed: "<39828"

Is there a way to change the macro code perhaps (or cell formatting)
to make that "< 15/01/2009" instead?

Thanks for any assistance!

Rob
:)
 
J

JB

Hello,

http://cjoint.com/?bshTcTRKcM
http://boisgontierjacques.free.fr/pages_site/FiltreAuto.htm

Function FiltreActuel(feuille, c As String, Optional typeCol As
String)
Application.Volatile
n = Sheets(feuille).Range("_FilterDataBase").Columns.Count
col = Application.Match(c, Sheets(feuille).Range
("_FilterDataBase").Cells(1, 1).Resize(1, n), 0)
If Sheets(feuille).FilterMode Then
If Sheets(feuille).AutoFilter.Filters.Item(col).On Then
temp = Sheets(feuille).AutoFilter.Filters.Item(col).Criteria1
If Left(temp, 2) = ">=" Or Left(temp, 2) = "<=" Then
o = Left(temp, 2): n = Mid(temp, 3)
Else
If Left(temp, 1) = "=" Or Left(temp, 1) = ">" Or Left(temp,
1) = "<" Then
o = Left(temp, 1): n = Mid(temp, 2)
Else
n = temp
End If
End If
If typeCol = "D" Then n = Format(n, "dd/mm/yy")
temp = o & n
'---
If Sheets(feuille).AutoFilter.Filters.Item(col).Operator Then
oper = IIf(Sheets(feuille).AutoFilter.Filters.Item
(col).Operator = 1, " ET ", " OU ")
On Error Resume Next
Err = 0
temp2 = Sheets(feuille).AutoFilter.Filters.Item
(col).Criteria2
If Err = 0 Then
If Left(temp2, 2) = ">=" Or Left(temp2, 2) = "<=" Then
o = Left(temp2, 2): n = Mid(temp2, 3)
Else
If Left(temp2, 1) = "=" Or Left(temp2, 1) = ">" Or Left
(temp2, 1) = "<" _
Then o = Left(temp2, 1): n = Mid(temp2, 2)
End If
If typeCol = "D" Then n = Format(n, "dd/mm/yy")
temp2 = o & n
Else
oper = ""
End If
End If
FiltreActuel = temp & oper & temp2
Else
FiltreActuel = ""
End If
Else
FiltreActuel = ""
End If
End Function

JB
http://boisgontierjacques.free.fr
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top