Sorting Problem

bradley7

Board Regular
Joined
Feb 22, 2005
Messages
102
Hi guys,
I'm sorting a spreasheet using column "D" as the key.
In this column, it contain data such as
CS 5.01
CS 6.01
New RElease

When i sort it using the pop-down menu, it work fine, I actually record this BUT what I put into the code of the Macro and it results as CS 5.01 is after CS 6.01

example

CS 6.01
CS 5.01
CS 6.01
CS 6.01
CS 6.02

The CS 5.01 is the only one out of order
SOMETHING WEIRD IS HAPPENING
 

Some videos you may like

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

nbrcrunch

Well-known Member
Joined
Jan 1, 2003
Messages
2,062
What I have found is that non-visible characters are usually the culprit.

First start by examining the length of the text using =LEN()

If you get anything back but 7, then you have extra spaces either at the front or back of your text.

Using something like this will help you determine what is in the field

=CODE(MID($A$1,COLUMN()-1,1))

The "-1" is because I put the above formula in column B. Without "-1", the formula would have started looking with the 2nd character.

Drag the formula over for how ever many characters there are in the source text.

Keep in mind that spaces should return code 32. If there is another code, then what have in your text is not a space but an unprintable (non-displayable) character.
 

DrShowMe

New Member
Joined
Nov 17, 2005
Messages
8
Alternately, perhaps when you use the pull down menu, you are indicating there is no header row (thus sorting all elements) but in the macro code you indicate there IS a header row (thus freezing the first entry).
 

Watch MrExcel Video

Forum statistics

Threads
1,118,736
Messages
5,573,921
Members
412,555
Latest member
mark84
Top