Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Updating workbook with an alpha sort sheet and a numeric sort shee | Excel Discussion (Misc queries) | |||
sort function for dates does not sort properly in Office 2007 Exc. | Excel Worksheet Functions | |||
Excel sort by Fill Color by custom list sort | Excel Discussion (Misc queries) | |||
sort (on part of) string - originally posted under Tricky Sort | Excel Programming | |||
Tricky Sort Issues | Excel Programming |