Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tim Tim is offline
external usenet poster
 
Posts: 145
Default excel date format problem

Dear All,

i'm trying to set a custom autofilter using VBA/inputboxes. everything
seems to work BUT I am trying to filter dates taken from inputboxes and in
the process, the days and months are being transposed... eg, in the
inputbox, i entered '1/6' meaning '1st June 2008' but the
autofilter is showing '6th January 2008'... obviously returning the wrong
result.

any ideas how to fix that?! I'm using the following syntax to set & use the
date variable: -
==
Dim rng1, rng2
rng1 = Format(CDate(InputBox("from")), "dd/mm/yyyy")
rng2 = Format(CDate(InputBox("to")), "dd/mm/yyyy")
Selection.AutoFilter Field:=3, Criteria1:="<=" & rng1, Operator:=xlAnd,
Criteria2:="=" & rng2
===

tia,

Tim


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default excel date format problem

Try this

Dim rng1, rng2
With Selection
rng1 = Format(CDate(InputBox("from")), .Cells(1,1).Numberformat)
rng2 = Format(CDate(InputBox("to")), .Cells(1,1).Numberformat)
.AutoFilter Field:=3, Criteria1:="<=" & rng1,
Operator:=xlAnd,Criteria2:="=" & rng2
End With

--
__________________________________
HTH

Bob

"Tim" <tmarsh-trousers-@-take off my trousers to reply-blueyonder.co.uk
wrote in message ...
Dear All,

i'm trying to set a custom autofilter using VBA/inputboxes. everything
seems to work BUT I am trying to filter dates taken from inputboxes and in
the process, the days and months are being transposed... eg, in the
inputbox, i entered '1/6' meaning '1st June 2008' but the
autofilter is showing '6th January 2008'... obviously returning the wrong
result.

any ideas how to fix that?! I'm using the following syntax to set & use
the
date variable: -
==
Dim rng1, rng2
rng1 = Format(CDate(InputBox("from")), "dd/mm/yyyy")
rng2 = Format(CDate(InputBox("to")), "dd/mm/yyyy")
Selection.AutoFilter Field:=3, Criteria1:="<=" & rng1, Operator:=xlAnd,
Criteria2:="=" & rng2
===

tia,

Tim



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
Excel Format Problem - Date Overrides Format Mary Excel Discussion (Misc queries) 5 February 10th 10 05:49 AM
Excel 2007 Date Format Problem terry Excel Discussion (Misc queries) 0 November 25th 06 06:16 AM
Problem with OpenText in Excel 2000 (date format) sorin Excel Programming 1 September 13th 05 06:03 PM
Date format problem in Excel Rama Bangaru Excel Programming 3 March 9th 05 09:40 AM
Excel 2003, problem with UK date format, using OLE Bill Dallas Excel Programming 1 August 18th 04 09:06 AM


All times are GMT +1. The time now is 01:46 PM.

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

About Us

"It's about Microsoft Excel"