Sorting "text" numbers

  • Thread starter Thread starter Chris
  • Start date Start date
C

Chris

I am sorting a list of numbers (actually telephone
extensions) which need to be formatted as text. When I
sort them I get two separate lists starting over again.

e.g. 1000,1001,1004,2003,3456,...,0456,1003,2455,...

I've check for leading spaces, format differences etc. but
this is not the problem.
 
Chris,

If the cells were formatted after entering the data, the currently entered
values aren't automatically converted from numbers to strings.

Do your sort, then select the first group of cells and run this macro:

Sub MakeText()
For Each myCell In Selection
myCell.Value = "'" & myCell.Value
Next myCell
End Sub

Then redo your sort, and all should work out.

HTH,
Bernie
MS Excel MVP
 

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