Link to home
Start Free TrialLog in
Avatar of Bright01
Bright01Flag for United States of America

asked on

Auto sort routine

EE Professionals,

I have a macro that looks for changes in a column of numbers.  When a number is added to the last column, it automatically "fits" the number into the proper sequence (Low to High).

Example;
1
2
3
4
5

Now if I add 3.2 in the last cell, it will reorder the column as;

1
2
3
3.2
4
5

The problem is, if I add 3.2.1, it will put it at the end of the column instead of after 3.2; apparently not recognizing the expanded requirement for another sub.

Any ideas on how to fix the recognition of the number or position based on this schema?

Thank you,

B.
Avatar of nap0leon
nap0leon

3.2 is a number
3.2.1 is text

numbers are < text

Change your values from:
1
2
3
3.2
3.2.1
4
5

to
'1
'2
'3
'3.2
'3.2.1
'4
'5

Now auto-sort will work as expected.

It is not enough to change the cell-type to "text", you have to use the single quotes.
There is probably a programmatic way of handling this, but the above is an explanation of what you are seeing.
Avatar of SANTABABY
I think to get you the desired result, you may need more. Because your sorted list should be ordered like:

1
2
3
3.2
4
5
.....
9
9.2
10.0
11.2
...

Am I right?

How many decimal points (maximum) you expect to see in your data to be sorted?
Are you okay if the solution uses an additional auxilary column for sorting?
Which version of Excel?
Avatar of Bright01

ASKER

I'm using Excel 2010.  I'd like to have two decimal points such as in an outline.  I tried to define the cells as "text" but it did not sort correctly with 2 decimal points.

B.
ASKER CERTIFIED SOLUTION
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
matthewspatrick!  This is great!  Thank you....... great job.

B.
I've requested that this question be closed as follows:

Accepted answer: 0 points for Bright01's comment http:/Q_27346423.html#36720769

for the following reason:

Great solution! &nbsp;You are clearly a &quot;problem solver&quot; or &quot;puzzle master&quot;!<br /><br />B.
I think you selected your own comment as the answer in error.
Excellent solution!

Much thanks!

B.