Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default xlSortTextAsNumbers inconsistent? Excel 2003

Hi All,

I am getting inconsistent behaviour on data between recording and running a
macro.

If I record a macro that selects all data, then sorts by an ID number (in
column A) and a date (in column B), I get asked the question about whether
Excel should treat everything as a number even though it thinks some things
are text, or sort numbers and text differently. I select treat all as
number, and the sorting works correctly - in UK formatting, 13/05/2005 is
before 02/06/2005 (assuming the same ID number).

The code generated is:

Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Key2:=Range("C2") _
, Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:=
_
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal,
DataOption2 _
:=xlSortTextAsNumbers


However, if I RUN that code, the reverse is true - the "real date" field
(the serialized number, 38xxx that is "true") seems to be used for the
comparison.

Am I missing something obvious that should go in the VBA code here?

Many thanks,

Dave


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default xlSortTextAsNumbers inconsistent? Excel 2003

Looks like this isn't the root of the problem - the root is that double
clicking on a csv has a different outcome than a
Workbooks.Open(fileNameVariable) call.

So I'm trying to figure out a way of opening within Excel that matches
opening manually by double clicking - any ideas?

Thanks,

Dave

"David Evans" wrote in message
...
Hi All,

I am getting inconsistent behaviour on data between recording and running
a macro.

If I record a macro that selects all data, then sorts by an ID number (in
column A) and a date (in column B), I get asked the question about whether
Excel should treat everything as a number even though it thinks some
things are text, or sort numbers and text differently. I select treat all
as number, and the sorting works correctly - in UK formatting, 13/05/2005
is before 02/06/2005 (assuming the same ID number).

The code generated is:

Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Key2:=Range("C2") _
, Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:=
_
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal,
DataOption2 _
:=xlSortTextAsNumbers


However, if I RUN that code, the reverse is true - the "real date" field
(the serialized number, 38xxx that is "true") seems to be used for the
comparison.

Am I missing something obvious that should go in the VBA code here?

Many thanks,

Dave



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
what is inconsistent formula in region in excel? Eric Excel Discussion (Misc queries) 1 July 22nd 09 05:32 AM
Dates display inconsistent in MS Excel 2007 Bagia Charts and Charting in Excel 0 May 5th 09 03:01 PM
Migrating Excel Data with inconsistent formats Paul Braswell Excel Discussion (Misc queries) 0 October 26th 06 05:06 PM
Excel/Outlook Inconsistent results Don Rouse Excel Programming 0 July 8th 05 07:29 PM
Excel 97 - Inconsistent Change Events TightCode Excel Programming 0 July 31st 03 06:00 PM


All times are GMT +1. The time now is 07:50 AM.

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"