A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Sorting a column with Text and Numbers



 
 
Thread Tools Display Modes
  #1  
Old November 11th, 2009, 09:59 PM posted to microsoft.public.excel.misc
tstobb
external usenet poster
 
Posts: 4
Default Sorting a column with Text and Numbers

I'm trying to sort a column that contains both text and numbers so that the
numbers appear in order instead of 1,10,11,12,19,20,21, etc. I can't use
text-to-columns because the text isn't uniform. When I sort, here's what i
currently get:
Computer Flex 1
Computer Flex 10
Computer Flex 11
Computer Flex 12
Computer Flex 13
Computer Flex 14
Computer Flex 15
Computer Flex 16
Computer Flex 17
Computer Flex 18
Computer Flex 19
Computer Flex 2
Computer Flex 20
Computer Flex 21
Computer Flex 3
Computer Flex 4
Computer Flex 5
Computer Flex 6
FOOD & COOKING Flex 1
FOOD & COOKING Flex 10
FOOD & COOKING Flex 11
FOOD & COOKING Flex 12
FOOD & COOKING Flex 13
FOOD & COOKING Flex 14
FOOD & COOKING Flex 15
FOOD & COOKING Flex 16
FOOD & COOKING Flex 17
FOOD & COOKING Flex 18
FOOD & COOKING Flex 19
FOOD & COOKING Flex 2


and here's what I need:

Computer Flex 1
Computer Flex 2
Computer Flex 3
Computer Flex 4
Computer Flex 5
Computer Flex 6
Computer Flex 10
Computer Flex 11
Computer Flex 12
Computer Flex 13
Computer Flex 14
Computer Flex 15
Computer Flex 16
Computer Flex 17
Computer Flex 18
Computer Flex 19
Computer Flex 20
Computer Flex 21
FOOD & COOKING Flex 1
FOOD & COOKING Flex 2
FOOD & COOKING Flex 10
FOOD & COOKING Flex 11
FOOD & COOKING Flex 12
FOOD & COOKING Flex 13
FOOD & COOKING Flex 14
FOOD & COOKING Flex 15
FOOD & COOKING Flex 16
FOOD & COOKING Flex 17
FOOD & COOKING Flex 18
FOOD & COOKING Flex 19

  #2  
Old November 11th, 2009, 11:46 PM posted to microsoft.public.excel.misc
Dave Peterson
external usenet poster
 
Posts: 19,791
Default Sorting a column with Text and Numbers

But if the data was always consistent -- variable text followed by a space
character, then numbers, you could use a formula to extract that last portion
and sort by that helper column...

One way:
=--trim(right(substitute(trim(a1)," ",rept(" ",99)),99))

It replaces the space character with 99 space characters and then looks at the
rightmost 99 characters. Trims that and the -- changes the text back to
numbers.

If your data isn't always laid out this way, you'll want to share more samples.

tstobb wrote:

I'm trying to sort a column that contains both text and numbers so that the
numbers appear in order instead of 1,10,11,12,19,20,21, etc. I can't use
text-to-columns because the text isn't uniform. When I sort, here's what i
currently get:
Computer Flex 1
Computer Flex 10
Computer Flex 11
Computer Flex 12
Computer Flex 13
Computer Flex 14
Computer Flex 15
Computer Flex 16
Computer Flex 17
Computer Flex 18
Computer Flex 19
Computer Flex 2
Computer Flex 20
Computer Flex 21
Computer Flex 3
Computer Flex 4
Computer Flex 5
Computer Flex 6
FOOD & COOKING Flex 1
FOOD & COOKING Flex 10
FOOD & COOKING Flex 11
FOOD & COOKING Flex 12
FOOD & COOKING Flex 13
FOOD & COOKING Flex 14
FOOD & COOKING Flex 15
FOOD & COOKING Flex 16
FOOD & COOKING Flex 17
FOOD & COOKING Flex 18
FOOD & COOKING Flex 19
FOOD & COOKING Flex 2

and here's what I need:

Computer Flex 1
Computer Flex 2
Computer Flex 3
Computer Flex 4
Computer Flex 5
Computer Flex 6
Computer Flex 10
Computer Flex 11
Computer Flex 12
Computer Flex 13
Computer Flex 14
Computer Flex 15
Computer Flex 16
Computer Flex 17
Computer Flex 18
Computer Flex 19
Computer Flex 20
Computer Flex 21
FOOD & COOKING Flex 1
FOOD & COOKING Flex 2
FOOD & COOKING Flex 10
FOOD & COOKING Flex 11
FOOD & COOKING Flex 12
FOOD & COOKING Flex 13
FOOD & COOKING Flex 14
FOOD & COOKING Flex 15
FOOD & COOKING Flex 16
FOOD & COOKING Flex 17
FOOD & COOKING Flex 18
FOOD & COOKING Flex 19


--

Dave Peterson
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:20 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.