Thread: macro's problem
View Single Post
  #2   Report Post  
Dave Peterson
 
Posts: n/a
Default

Dates can be a problem in VBA.

This may work:

Selection.AutoFilter Field:=21, Criteria1:="<="&clng(dateserial(2005,9,30))



gerry405 wrote:

Firstly, excuse my ignorance in advance to those who make coding in VB
look so easy!

Hi everyone

Can anyone show me how to filter on a column containing dates in the
format of 21/04/59 being (21st April 1959), I set about recording a
macro that first put a filter on the worksheet, then I selected the
column with dates in and go to custom filter then select "equal to or
lesser than" and key in the value 30/09/2005, but all that happens when
I run this is I get blank lines ...

code below

Sub less_than()
'
' less_than Macro
' Macro recorded 07/10/2005 by SGUHT
'
' Keyboard Shortcut: Ctrl+k
'
Selection.AutoFilter
Range("U1").Select
Selection.AutoFilter Field:=21, Criteria1:="<=30/09/2005",
Operator:= _
xlAnd
End Sub

--
gerry405


--

Dave Peterson