Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Problem with date formatting

Hi
Below is part of a Macro to Autofilter by a date in cell "N1".

Range("N1").Select
Selection.NumberFormat = "dd/mm/yyyy;@"

Columns("A:A").Select
Selection.NumberFormat = "dd/mm/yyyy;@"


Range("A2").AutoFilter Field:=1, Criteria1:="<" & Range("n1"),
Operator:=xlAnd

I formatted the values in N1 and column A to be the same date format
to hopefully avoid problems, however the filter does not work.


Dates like 13/07/2010 and 12/07/2010 get formatted to
13/07/10 and 07/12/2010 respectively (both should be filtered out
as the date in N1 is greater than both dates however only the
07/12/2010 gets filtered)

Is there another way to format these dates to make my filter work.

Much appreciated

Eddie

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 834
Default Problem with date formatting

Maybe try

Range("A2").AutoFilter Field:=1, _
Criteria1:="<" & Format(Range("N1"),Range("A2").NumberFormat), _
Operator:=xlAnd

--

HTH

Bob

"webels" wrote in message
...
Hi
Below is part of a Macro to Autofilter by a date in cell "N1".

Range("N1").Select
Selection.NumberFormat = "dd/mm/yyyy;@"

Columns("A:A").Select
Selection.NumberFormat = "dd/mm/yyyy;@"


Range("A2").AutoFilter Field:=1, Criteria1:="<" & Range("n1"),
Operator:=xlAnd

I formatted the values in N1 and column A to be the same date format
to hopefully avoid problems, however the filter does not work.


Dates like 13/07/2010 and 12/07/2010 get formatted to
13/07/10 and 07/12/2010 respectively (both should be filtered out
as the date in N1 is greater than both dates however only the
07/12/2010 gets filtered)

Is there another way to format these dates to make my filter work.

Much appreciated

Eddie



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 834
Default Problem with date formatting

As a double safety

Maybe try

Range("A2").AutoFilter Field:=1, _
Criteria1:="<" &
Format(CDate(Range("N1").Value),Range("A2").Number Format), _
Operator:=xlAnd

--

HTH

Bob

"Bob Phillips" wrote in message
...
Maybe try

Range("A2").AutoFilter Field:=1, _
Criteria1:="<" & Format(Range("N1"),Range("A2").NumberFormat), _
Operator:=xlAnd

--

HTH

Bob

"webels" wrote in message
...
Hi
Below is part of a Macro to Autofilter by a date in cell "N1".

Range("N1").Select
Selection.NumberFormat = "dd/mm/yyyy;@"

Columns("A:A").Select
Selection.NumberFormat = "dd/mm/yyyy;@"


Range("A2").AutoFilter Field:=1, Criteria1:="<" & Range("n1"),
Operator:=xlAnd

I formatted the values in N1 and column A to be the same date format
to hopefully avoid problems, however the filter does not work.


Dates like 13/07/2010 and 12/07/2010 get formatted to
13/07/10 and 07/12/2010 respectively (both should be filtered out
as the date in N1 is greater than both dates however only the
07/12/2010 gets filtered)

Is there another way to format these dates to make my filter work.

Much appreciated

Eddie





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Problem with date formatting

On Jul 20, 9:34*am, "Bob Phillips" wrote:
As a double safety

Maybe try

Range("A2").AutoFilter Field:=1, _
* * * * Criteria1:="<" &
Format(CDate(Range("N1").Value),Range("A2").Number Format), _
* * * * Operator:=xlAnd

--

HTH

Bob

"Bob Phillips" wrote in message

...



Maybe try


Range("A2").AutoFilter Field:=1, _
* * * *Criteria1:="<" & Format(Range("N1"),Range("A2").NumberFormat), _
* * * *Operator:=xlAnd


--


HTH


Bob


"webels" wrote in message
....
Hi
Below is part of a Macro to Autofilter by a date in cell "N1".


Range("N1").Select
* *Selection.NumberFormat = "dd/mm/yyyy;@"


* *Columns("A:A").Select
* *Selection.NumberFormat = "dd/mm/yyyy;@"


* Range("A2").AutoFilter Field:=1, Criteria1:="<" & Range("n1"),
Operator:=xlAnd


I formatted the values in N1 and column A to be the same date format
to hopefully avoid problems, however the filter does not work.


Dates like 13/07/2010 and 12/07/2010 get formatted to
13/07/10 * and * 07/12/2010 respectively (both should be filtered out
as the date in N1 is greater than both dates however only the
07/12/2010 gets filtered)


Is there another way to format these dates to make my filter work.


Much appreciated


Eddie


Thanks Bob
Will try this and see
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Problem with date formatting

On Jul 20, 5:34*pm, "Bob Phillips" wrote:
As a double safety

Maybe try

Range("A2").AutoFilter Field:=1, _
* * * * Criteria1:="<" &
Format(CDate(Range("N1").Value),Range("A2").Number Format), _
* * * * Operator:=xlAnd

--

HTH

Bob

"Bob Phillips" wrote in message

...



Maybe try


Range("A2").AutoFilter Field:=1, _
* * * *Criteria1:="<" & Format(Range("N1"),Range("A2").NumberFormat), _
* * * *Operator:=xlAnd


--


HTH


Bob


"webels" wrote in message
....
Hi
Below is part of a Macro to Autofilter by a date in cell "N1".


Range("N1").Select
* *Selection.NumberFormat = "dd/mm/yyyy;@"


* *Columns("A:A").Select
* *Selection.NumberFormat = "dd/mm/yyyy;@"


* Range("A2").AutoFilter Field:=1, Criteria1:="<" & Range("n1"),
Operator:=xlAnd


I formatted the values in N1 and column A to be the same date format
to hopefully avoid problems, however the filter does not work.


Dates like 13/07/2010 and 12/07/2010 get formatted to
13/07/10 * and * 07/12/2010 respectively (both should be filtered out
as the date in N1 is greater than both dates however only the
07/12/2010 gets filtered)


Is there another way to format these dates to make my filter work.


Much appreciated


Eddie- Hide quoted text -


- Show quoted text -


Hi Bob
This didn't seem to work, I am still left with dates after the date in
"N1". I should explain myself better. I ahve dates in Column A and I
am trying to delete rows that have dates from Today() minus 56 days
inclusive.

Much appreciated
Eddie


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Problem with date formatting

On Jul 20, 9:34*am, "Bob Phillips" wrote:
As a double safety

Maybe try

Range("A2").AutoFilter Field:=1, _
* * * * Criteria1:="<" &
Format(CDate(Range("N1").Value),Range("A2").Number Format), _
* * * * Operator:=xlAnd

--

HTH

Bob

"Bob Phillips" wrote in message

...



Maybe try


Range("A2").AutoFilter Field:=1, _
* * * *Criteria1:="<" & Format(Range("N1"),Range("A2").NumberFormat), _
* * * *Operator:=xlAnd


--


HTH


Bob


"webels" wrote in message
....
Hi
Below is part of a Macro to Autofilter by a date in cell "N1".


Range("N1").Select
* *Selection.NumberFormat = "dd/mm/yyyy;@"


* *Columns("A:A").Select
* *Selection.NumberFormat = "dd/mm/yyyy;@"


* Range("A2").AutoFilter Field:=1, Criteria1:="<" & Range("n1"),
Operator:=xlAnd


I formatted the values in N1 and column A to be the same date format
to hopefully avoid problems, however the filter does not work.


Dates like 13/07/2010 and 12/07/2010 get formatted to
13/07/10 * and * 07/12/2010 respectively (both should be filtered out
as the date in N1 is greater than both dates however only the
07/12/2010 gets filtered)


Is there another way to format these dates to make my filter work.


Much appreciated


Eddie


Hi Bob
Just to let you know. I got this sorted, thanks for the lead..
Much appreciated
Eddie
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Date Formatting Problem John Calder New Users to Excel 3 August 12th 09 12:22 AM
Date Formatting problem laralea Excel Discussion (Misc queries) 5 January 23rd 06 07:07 PM
Date formatting problem Anne CFS Excel Discussion (Misc queries) 1 July 19th 05 01:31 PM
Date formatting problem greg7468 Excel Discussion (Misc queries) 4 July 7th 05 09:44 PM
Problem with Date Formatting The Data Detective Excel Discussion (Misc queries) 0 March 30th 05 12:57 AM


All times are GMT +1. The time now is 10:13 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"