ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Filtering TIME/DATE (https://www.excelbanter.com/excel-programming/344740-filtering-time-date.html)

Mark

Filtering TIME/DATE
 
I am using excel 97. I am trying to filter a worksheet of data which
contains a column of a time/date in this format: 02:05 03/11/05

I want to be able to create a custom filter in VBA of: = 07:00 03/11/05 or
<= 0659 04/11/05 but for some reason when I do it will not work. The
formatting of the column is 'GENERAL', however as a matter if interest when a
cell of this type is clicked on the format changes to 'CUSTOM' dd/mm/yyyy
hh:mm

Can someone come up with code as a solution for me, please?

--
Mark

Tom Ogilvy

Filtering TIME/DATE
 
for a start, turn on the macro recorder and apply your filter.

See how it records the criteria.

Also, your dates are ambiguous - are the mm/dd/yy or dd/mm/yy. VBA is
looking for mm/dd/yy

--
Regards,
Tom Ogilvy

"Mark" wrote in message
...
I am using excel 97. I am trying to filter a worksheet of data which
contains a column of a time/date in this format: 02:05 03/11/05

I want to be able to create a custom filter in VBA of: = 07:00 03/11/05

or
<= 0659 04/11/05 but for some reason when I do it will not work. The
formatting of the column is 'GENERAL', however as a matter if interest

when a
cell of this type is clicked on the format changes to 'CUSTOM' dd/mm/yyyy
hh:mm

Can someone come up with code as a solution for me, please?

--
Mark




Mark

Filtering TIME/DATE
 
I have already done that to see what is reproduced in VBA and here's what it
is recorded:

Selection.AutoFilter
Selection.AutoFilter Field:=12, Criteria1:="=03/11/2005 07:00",
Operator _
:=xlAnd, Criteria2:="<=04/11/2005 06:59"

The spreadsheet format is different to what is recorded, the date format on
the spreadsheet should be dd/mm/yyyy.

--
Mark


"Tom Ogilvy" wrote:

for a start, turn on the macro recorder and apply your filter.

See how it records the criteria.

Also, your dates are ambiguous - are the mm/dd/yy or dd/mm/yy. VBA is
looking for mm/dd/yy

--
Regards,
Tom Ogilvy

"Mark" wrote in message
...
I am using excel 97. I am trying to filter a worksheet of data which
contains a column of a time/date in this format: 02:05 03/11/05

I want to be able to create a custom filter in VBA of: = 07:00 03/11/05

or
<= 0659 04/11/05 but for some reason when I do it will not work. The
formatting of the column is 'GENERAL', however as a matter if interest

when a
cell of this type is clicked on the format changes to 'CUSTOM' dd/mm/yyyy
hh:mm

Can someone come up with code as a solution for me, please?

--
Mark





Tom Ogilvy

Filtering TIME/DATE
 
but in VBA it should be mm/dd/yyyy. Try that and see if your filter doesn't
work.

Selection.AutoFilter
Selection.AutoFilter Field:=12, Criteria1:="=11/03/2005 07:00", _
Operator:=xlAnd, Criteria2:="<=11/04/2005 06:59"

--
Regards,
Tom Ogilvy

"Mark" wrote in message
...
I have already done that to see what is reproduced in VBA and here's what

it
is recorded:

Selection.AutoFilter
Selection.AutoFilter Field:=12, Criteria1:="=03/11/2005 07:00",
Operator _
:=xlAnd, Criteria2:="<=04/11/2005 06:59"

The spreadsheet format is different to what is recorded, the date format

on
the spreadsheet should be dd/mm/yyyy.

--
Mark


"Tom Ogilvy" wrote:

for a start, turn on the macro recorder and apply your filter.

See how it records the criteria.

Also, your dates are ambiguous - are the mm/dd/yy or dd/mm/yy. VBA is
looking for mm/dd/yy

--
Regards,
Tom Ogilvy

"Mark" wrote in message
...
I am using excel 97. I am trying to filter a worksheet of data which
contains a column of a time/date in this format: 02:05 03/11/05

I want to be able to create a custom filter in VBA of: = 07:00

03/11/05
or
<= 0659 04/11/05 but for some reason when I do it will not work. The
formatting of the column is 'GENERAL', however as a matter if interest

when a
cell of this type is clicked on the format changes to 'CUSTOM'

dd/mm/yyyy
hh:mm

Can someone come up with code as a solution for me, please?

--
Mark







Dave Peterson

Filtering TIME/DATE
 
Maybe...

Selection.AutoFilter
Selection.AutoFilter Field:=12, _
Criteria1:="=" & dateserial(2005,11,3) + timeserial(7,0,0), _
Operator:=xlAnd, _
Criteria2:="<=" & dateserial(2005,11,4) + timeserial(6,59,0)





Mark wrote:

I have already done that to see what is reproduced in VBA and here's what it
is recorded:

Selection.AutoFilter
Selection.AutoFilter Field:=12, Criteria1:="=03/11/2005 07:00",
Operator _
:=xlAnd, Criteria2:="<=04/11/2005 06:59"

The spreadsheet format is different to what is recorded, the date format on
the spreadsheet should be dd/mm/yyyy.

--
Mark

"Tom Ogilvy" wrote:

for a start, turn on the macro recorder and apply your filter.

See how it records the criteria.

Also, your dates are ambiguous - are the mm/dd/yy or dd/mm/yy. VBA is
looking for mm/dd/yy

--
Regards,
Tom Ogilvy

"Mark" wrote in message
...
I am using excel 97. I am trying to filter a worksheet of data which
contains a column of a time/date in this format: 02:05 03/11/05

I want to be able to create a custom filter in VBA of: = 07:00 03/11/05

or
<= 0659 04/11/05 but for some reason when I do it will not work. The
formatting of the column is 'GENERAL', however as a matter if interest

when a
cell of this type is clicked on the format changes to 'CUSTOM' dd/mm/yyyy
hh:mm

Can someone come up with code as a solution for me, please?

--
Mark





--

Dave Peterson

Mark

Filtering TIME/DATE
 
Sorry still won't work!

However I recorded what happened when I clicked on a cell:

ActiveCell.FormulaR1C1 = "11/3/2005 1:35"

Which is as you quite rightly stated m/d/yyyy

I changed the vba to suit but it still doesn't work!


--
Mark


"Tom Ogilvy" wrote:

but in VBA it should be mm/dd/yyyy. Try that and see if your filter doesn't
work.

Selection.AutoFilter
Selection.AutoFilter Field:=12, Criteria1:="=11/03/2005 07:00", _
Operator:=xlAnd, Criteria2:="<=11/04/2005 06:59"

--
Regards,
Tom Ogilvy

"Mark" wrote in message
...
I have already done that to see what is reproduced in VBA and here's what

it
is recorded:

Selection.AutoFilter
Selection.AutoFilter Field:=12, Criteria1:="=03/11/2005 07:00",
Operator _
:=xlAnd, Criteria2:="<=04/11/2005 06:59"

The spreadsheet format is different to what is recorded, the date format

on
the spreadsheet should be dd/mm/yyyy.

--
Mark


"Tom Ogilvy" wrote:

for a start, turn on the macro recorder and apply your filter.

See how it records the criteria.

Also, your dates are ambiguous - are the mm/dd/yy or dd/mm/yy. VBA is
looking for mm/dd/yy

--
Regards,
Tom Ogilvy

"Mark" wrote in message
...
I am using excel 97. I am trying to filter a worksheet of data which
contains a column of a time/date in this format: 02:05 03/11/05

I want to be able to create a custom filter in VBA of: = 07:00

03/11/05
or
<= 0659 04/11/05 but for some reason when I do it will not work. The
formatting of the column is 'GENERAL', however as a matter if interest
when a
cell of this type is clicked on the format changes to 'CUSTOM'

dd/mm/yyyy
hh:mm

Can someone come up with code as a solution for me, please?

--
Mark








All times are GMT +1. The time now is 11:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com