View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
elsandalos elsandalos is offline
external usenet poster
 
Posts: 3
Default Date flips around when using Autofilter in VB

I'm using VB to autofilter a number of worksheets using a criteria entered in
a textbox.

--------------------------------------------------------------------------------
Sub Filter_Box3()

Dim ws As Worksheet
Dim crit As String
Dim agsheetname As String

crit = Sheet1.Filtertext2.Value

Application.ScreenUpdating = False

For Each ws In Worksheets
agsheetname = ws.Name
If agsheetname < "Guide" Then

ws.UsedRange.AutoFilter Field:=1, Criteria1:="<" & crit

End If

Next ws

Application.ScreenUpdating = True

End Sub

--------------------------------------------------------------------------------

for some reason, when using < or the date has been flipped around when i
check the autofilter settings on the worksheets, so that if crit =
01/02/2005, it gets changed to 02/01/2005. This does not happen when using =
in the criteria. Even when i hard code a date into the function like:

-------------------------------------------------------------------------------
ws.UsedRange.AutoFilter Field:=1, Criteria1:="<01/02/2005"

--------------------------------------------------------------------------------

.... it still gets flipped around.

Any ideas?

El.