View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
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