jfgreen123
New Member
- Joined
- Jan 17, 2005
- Messages
- 6
Hello all,
I have a worksheet with dates in the UK dd/mm/yy format. The macros I have written which include an autofilter on the dates works with no problems for my English colleagues.
However we have some German colleagues in the office who have their regional settings on German, so their default date format is dd.mm.yy. This causes a problem with the autofilter of the date.
I have tried two solutions:
1. Check the date separator format in the International property and code the date for the autofilter to use the correct separator.
If Application.International(xlDateSeparator) = "/" Then
ActiveSheet.Range("$B$3:$D$6").AutoFilter Field:=3, Criteria1:= _
">01/03/2014", Operator:=xlAnd, Criteria2:="<01/04/2014"
End If
If Application.International(xlDateSeparator) = "." Then
ActiveSheet.Range("$B$3:$D$6").AutoFilter Field:=3, Criteria1:= _
">01.03.2014", Operator:=xlAnd, Criteria2:="<01.04.2014"
End If
2. To use the DateSerial function in the autofilter.
ActiveSheet.Range("$B$3:$D$6").AutoFilter Field:=3, _
Criteria1:=">=" & DateSerial(2014, 3, 1), Operator:=xlAnd, _
Criteria2:="<" & DateSerial(2014, 4, 1)
In both cases I get no data returned, but if I go manually into the autofilter drop down the values are there and a simple OK to the
dialogue box will return the correct results.
Any ideas what is going wrong, or how to correct it?
Thanks
John
I have a worksheet with dates in the UK dd/mm/yy format. The macros I have written which include an autofilter on the dates works with no problems for my English colleagues.
However we have some German colleagues in the office who have their regional settings on German, so their default date format is dd.mm.yy. This causes a problem with the autofilter of the date.
I have tried two solutions:
1. Check the date separator format in the International property and code the date for the autofilter to use the correct separator.
If Application.International(xlDateSeparator) = "/" Then
ActiveSheet.Range("$B$3:$D$6").AutoFilter Field:=3, Criteria1:= _
">01/03/2014", Operator:=xlAnd, Criteria2:="<01/04/2014"
End If
If Application.International(xlDateSeparator) = "." Then
ActiveSheet.Range("$B$3:$D$6").AutoFilter Field:=3, Criteria1:= _
">01.03.2014", Operator:=xlAnd, Criteria2:="<01.04.2014"
End If
2. To use the DateSerial function in the autofilter.
ActiveSheet.Range("$B$3:$D$6").AutoFilter Field:=3, _
Criteria1:=">=" & DateSerial(2014, 3, 1), Operator:=xlAnd, _
Criteria2:="<" & DateSerial(2014, 4, 1)
In both cases I get no data returned, but if I go manually into the autofilter drop down the values are there and a simple OK to the
dialogue box will return the correct results.
Any ideas what is going wrong, or how to correct it?
Thanks
John