Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default My Sort has Issues

I have a working macro that has developed issues. Within the macro there is a
sort command that has worked on every file that I have created to this point.
The latest file I tried to run through the macro didn't sort right. It is
sorting by product codes. The sort triggers calculations from a particular
code in the sheet forward. So, this error is major. It is causing
calculations to be performed unneccessarily and causing our figures to be
wrong. Can anyone tell me a reason why a product that began with the same
letters would sort half at the top and half at the bottom? Here's the code
for the sort:

Range("A1:N55").Sort Key1:=Range("D2"), Order1:=xlAscending, Header:= _
xlYes, OrderCustom:=1, MatchCase:=True, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

It has worked everytime. I cannot find any differences in the codes that
sorted seperately, no hidden characters, nothing!!! Does anyone know why this
could be happening? Do I need a patch? Or change the code? Any and all help
is greatly appreciated.
--
A Waller
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default My Sort has Issues

You said with the same letters, but I suspect all the characters in the code
are numbers. some of the cells with the numbers are probably storing the
code as numbers and some as text. These would sort to different areas.

You can fix your data or change the parameter for DataOption1 to

DataOption1:=xlSortTextAsNumbers

--
Regards,
Tom Ogilvy



"A Waller" wrote in message
...
I have a working macro that has developed issues. Within the macro there

is a
sort command that has worked on every file that I have created to this

point.
The latest file I tried to run through the macro didn't sort right. It is
sorting by product codes. The sort triggers calculations from a particular
code in the sheet forward. So, this error is major. It is causing
calculations to be performed unneccessarily and causing our figures to be
wrong. Can anyone tell me a reason why a product that began with the same
letters would sort half at the top and half at the bottom? Here's the code
for the sort:

Range("A1:N55").Sort Key1:=Range("D2"), Order1:=xlAscending, Header:= _
xlYes, OrderCustom:=1, MatchCase:=True,

Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

It has worked everytime. I cannot find any differences in the codes that
sorted seperately, no hidden characters, nothing!!! Does anyone know why

this
could be happening? Do I need a patch? Or change the code? Any and all

help
is greatly appreciated.
--
A Waller



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default My Sort has Issues

That worked. Thank you so much! It was driving me crazy. You are the best!

"Tom Ogilvy" wrote:

You said with the same letters, but I suspect all the characters in the code
are numbers. some of the cells with the numbers are probably storing the
code as numbers and some as text. These would sort to different areas.

You can fix your data or change the parameter for DataOption1 to

DataOption1:=xlSortTextAsNumbers

--
Regards,
Tom Ogilvy



"A Waller" wrote in message
...
I have a working macro that has developed issues. Within the macro there

is a
sort command that has worked on every file that I have created to this

point.
The latest file I tried to run through the macro didn't sort right. It is
sorting by product codes. The sort triggers calculations from a particular
code in the sheet forward. So, this error is major. It is causing
calculations to be performed unneccessarily and causing our figures to be
wrong. Can anyone tell me a reason why a product that began with the same
letters would sort half at the top and half at the bottom? Here's the code
for the sort:

Range("A1:N55").Sort Key1:=Range("D2"), Order1:=xlAscending, Header:= _
xlYes, OrderCustom:=1, MatchCase:=True,

Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

It has worked everytime. I cannot find any differences in the codes that
sorted seperately, no hidden characters, nothing!!! Does anyone know why

this
could be happening? Do I need a patch? Or change the code? Any and all

help
is greatly appreciated.
--
A Waller




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
Updating workbook with an alpha sort sheet and a numeric sort shee cjlatta Excel Discussion (Misc queries) 2 January 28th 09 12:00 AM
sort function for dates does not sort properly in Office 2007 Exc. Rosalie Excel Worksheet Functions 1 November 22nd 07 10:25 PM
Excel sort by Fill Color by custom list sort Dash4Cash Excel Discussion (Misc queries) 2 July 29th 05 10:45 PM
sort (on part of) string - originally posted under Tricky Sort Tom Ogilvy Excel Programming 0 August 6th 04 02:42 AM
Tricky Sort Issues Starting to Program[_3_] Excel Programming 0 August 4th 04 11:23 PM


All times are GMT +1. The time now is 11:01 AM.

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"