Thread: Bad code
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Oldjay[_2_] Oldjay[_2_] is offline
external usenet poster
 
Posts: 9
Default Bad code

When I run the code it doesn't return any records but if I substitute the
actual date in the criteriai it returns the correct records

sub test()
Dim birthdate As Date
Dim birthdate1 As Date
birthdate = Range("Form!C47") ' this value is 12/1/05 when you hover
over "birthdate"
birthdate1 = Range("Form!C48") ' This value is 12/31/05 when you hover
over "birthdate1"

Sheets("Records").Select
Range("J2").Select
Selection.AutoFilter

This filter returns no records
Selection.AutoFilter Field:=10, Criteria1:="=(birthdate)",
Operator:=xlAnd, _
Criteria2:="<=(birthdate1)"

This filter returns no records
Selection.AutoFilter Field:=10, Criteria1:="=12/1/05", Operator:=xlAnd,
_
Criteria2:="<=(12/31/05"

endsub

What I am I doing wrong?

oldjay