Sorting

  • Thread starter Thread starter Ulf Nilsson
  • Start date Start date
U

Ulf Nilsson

I have a long list of numbers, such as:
106-89-8
141-43-5
197-77-81
50-00-0

When I sort the cells, the 50-00-0 comes either first or
last. I want Excel to sort 50-00-0 first since "50" is
lower than "106". How is this done? The list contains
over 500 entries.

/ Ulf
 
Hi Ulf,

Assuming that the you want them sorted according to the numbers before
the first hyphen, and your data is in Column A, you can use a helper
column, say Column B, put the following formula, copy down, and sort on
Column B:

=--LEFT(A1,FIND("-",A1)-1)

Hope this helps!
 
Because of the hyphens, the data is treated as text, and the list is
sorted alphabetically, not as a number. Since 5 is greater than 1, all
the items that start with a 1 will sort before the item that starts with
a 5.

You could enter the numbers in three columns, then concatenate the
numbers, and add the hyphens in a fourth column. Then, sort by the
columns that contain the separated numbers. For example

A B C D
1 106 89 8 =A1&"-"&B1&"-"&C1
 
If you want to sort based on the entire number, you can first separate
them into three different columns using Text to Columns and hyphen as
your delimiter, then sort using Columns A, B, and C, and then put them
back together using something like =A1&"-"&B1&"-"&C1.

Hope this helps!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top