Simple Sort question Text and number

JimGunther

Board Regular
Joined
Oct 22, 2006
Messages
57
I have a sheet with a column which contains text, then, a number.
When I sort, the result is not as expected.

see BELOW

I'm fine with the first part but, want 1 then 2, then 3 rather than 1 then 10, then, 100

Somehow I thinks this has been covered and, maybe even a basic function of Excel but, I haven't been able to 'figger it.

As always, TIA Jim

" 1004Fort991
1004Fort993
1004Fort994
1004Fort995
1004Fort996
1004Fort997
1004Fort998
1004Fort999
1004FortGone
1105ForGlob1
1105ForGlob10
1105ForGlob100
1105ForGlob1000
1105ForGlob1001
1105ForGlob1002
1105ForGlob1003
1105ForGlob1003"
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Hi Jim,

I've probably misunderstood what you are requiring, but is this something like you want?....

Before sorting, copy the formula in A2 down

Excel Workbook
AB
211004Fort991
331004Fort993
441004Fort994
551004Fort995
661004Fort996
771004Fort997
881004Fort998
991004Fort999
10e1004FortGone
1111105ForGlob1
1201105ForGlob10
1301105ForGlob100
1401105ForGlob1000
1511105ForGlob1001
1621105ForGlob1002
1731105ForGlob1003
1831105ForGlob1003
Sheet4



After sorting by column A.....


Excel Workbook
AB
201105ForGlob10
301105ForGlob100
401105ForGlob1000
511004Fort991
611105ForGlob1
711105ForGlob1001
821105ForGlob1002
931004Fort993
1031105ForGlob1003
1131105ForGlob1003
1241004Fort994
1351004Fort995
1461004Fort996
1571004Fort997
1681004Fort998
1791004Fort999
18e1004FortGone
Sheet4



I hope that helps

Good luck

Ak
 
Upvote 0
Thanks Ak,

I tried that but it didn't produce the result expected (and I'm not clear on the logic)

I probably didn't state my question very clearly.

My sheet consists of Fortune 1000 Companies and Forbes Global 2000 companies. Thus, the 1104Fort and the 1105ForGlob prefixs before the ranking numbers (i.e. 1 thru 1,000 and 1 thru 2000 respectivily).

I would like the column BELOW to sort as, 11,110,111, 1097,1099,1100,1101 etc.

BTW: I did 'fiigger an easy-enough work-around - simply doing a find "ForGlob" and replace "with nothing" which gice a pure numerical sort but - if possible - I'd like to sort the mixed in the text and numerical fashion (Now that I asked the question, somebody else might want to do this.).

1105ForGlob1097
1105ForGlob1099
1105ForGlob11
1105ForGlob11
1105ForGlob110
1105ForGlob1100
1105ForGlob1101
1105ForGlob1102
1105ForGlob1103
1105ForGlob1103
1105ForGlob1105
1105ForGlob1105
1105ForGlob1107
1105ForGlob1108
1105ForGlob1109
1105ForGlob111
1105ForGlob1110
1105ForGlob1110
 
Upvote 0
Hi Jim

This solution requires an array formula, so it will take some time to calculate 3000 items.
Columns B:F show how the formula in column G is build.
With ideas from http://www.excelformeln.de/formeln.html?welcher=101.

<table valign="middle" colspan="8" style="font-family: Calibri; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-size: 11px; font-weight: normal; font-style: normal;" border="1" cellpadding="2" cellspacing="0"><colgroup><col width="28pt"><col width="95,25pt"><col width="60pt"><col width="60pt"><col width="60pt"><col width="78pt"><col width="93,75pt"><col width="93,75pt"></colgroup><tbody><tr style="background-color: rgb(250, 250, 250);"><td colspan="8" align="middle">Worksheet 'Tabelle1'</td></tr><tr style="background-color: rgb(202, 202, 202);"><td>
</td><td align="middle">A</td><td align="middle">B</td><td align="middle">C</td><td align="middle">D</td><td align="middle">E</td><td align="middle">F</td><td align="middle">G</td></tr><tr><td style="background-color: rgb(202, 202, 202);" align="middle">1</td><td align="left">1004Fort991</td><td align="left">991</td><td align="left">0991</td><td align="left">1004</td><td align="left">Fort0991</td><td align="left">1004Fort0991</td><td align="left">1004Fort0991</td></tr><tr><td style="background-color: rgb(202, 202, 202);" align="middle">2</td><td align="left">1004Fort993</td><td align="left">993</td><td align="left">0993</td><td align="left">1004</td><td align="left">Fort0993</td><td align="left">1004Fort0993</td><td align="left">1004Fort0993</td></tr><tr><td style="background-color: rgb(202, 202, 202);" align="middle">3</td><td align="left">1004Fort994</td><td align="left">994</td><td align="left">0994</td><td align="left">1004</td><td align="left">Fort0994</td><td align="left">1004Fort0994</td><td align="left">1004Fort0994</td></tr><tr><td style="background-color: rgb(202, 202, 202);" align="middle">4</td><td align="left">1004Fort995</td><td align="left">995</td><td align="left">0995</td><td align="left">1004</td><td align="left">Fort0995</td><td align="left">1004Fort0995</td><td align="left">1004Fort0995</td></tr><tr><td style="background-color: rgb(202, 202, 202);" align="middle">5</td><td align="left">1004Fort996</td><td align="left">996</td><td align="left">0996</td><td align="left">1004</td><td align="left">Fort0996</td><td align="left">1004Fort0996</td><td align="left">1004Fort0996</td></tr><tr><td style="background-color: rgb(202, 202, 202);" align="middle">6</td><td align="left">1004Fort997</td><td align="left">997</td><td align="left">0997</td><td align="left">1004</td><td align="left">Fort0997</td><td align="left">1004Fort0997</td><td align="left">1004Fort0997</td></tr><tr><td style="background-color: rgb(202, 202, 202);" align="middle">7</td><td align="left">1004Fort998</td><td align="left">998</td><td align="left">0998</td><td align="left">1004</td><td align="left">Fort0998</td><td align="left">1004Fort0998</td><td align="left">1004Fort0998</td></tr><tr><td style="background-color: rgb(202, 202, 202);" align="middle">8</td><td align="left">1004Fort999</td><td align="left">999</td><td align="left">0999</td><td align="left">1004</td><td align="left">Fort0999</td><td align="left">1004Fort0999</td><td align="left">1004Fort0999</td></tr><tr><td style="background-color: rgb(202, 202, 202);" align="middle">9</td><td align="left">1004FortGone</td><td align="left">
</td><td align="left">
</td><td align="left">1004</td><td align="left">FortGone</td><td align="left">1004FortGone</td><td align="left">1004FortGone</td></tr><tr><td style="background-color: rgb(202, 202, 202);" align="middle">10</td><td align="left">1105ForGlob1</td><td align="left">1</td><td align="left">0001</td><td align="left">1105</td><td align="left">ForGlob0001</td><td align="left">1105ForGlob0001</td><td align="left">1105ForGlob0001</td></tr><tr><td style="background-color: rgb(202, 202, 202);" align="middle">11</td><td align="left">1105ForGlob10</td><td align="left">10</td><td align="left">0010</td><td align="left">1105</td><td align="left">ForGlob0010</td><td align="left">1105ForGlob0010</td><td align="left">1105ForGlob0010</td></tr><tr><td style="background-color: rgb(202, 202, 202);" align="middle">12</td><td align="left">1105ForGlob100</td><td align="left">100</td><td align="left">0100</td><td align="left">1105</td><td align="left">ForGlob0100</td><td align="left">1105ForGlob0100</td><td align="left">1105ForGlob0100</td></tr><tr><td style="background-color: rgb(202, 202, 202);" align="middle">13</td><td align="left">1105ForGlob1000</td><td align="left">1000</td><td align="left">1000</td><td align="left">1105</td><td align="left">ForGlob1000</td><td align="left">1105ForGlob1000</td><td align="left">1105ForGlob1000</td></tr><tr><td style="background-color: rgb(202, 202, 202);" align="middle">14</td><td align="left">1105ForGlob1001</td><td align="left">1001</td><td align="left">1001</td><td align="left">1105</td><td align="left">ForGlob1001</td><td align="left">1105ForGlob1001</td><td align="left">1105ForGlob1001</td></tr><tr><td style="background-color: rgb(202, 202, 202);" align="middle">15</td><td align="left">1105ForGlob1002</td><td align="left">1002</td><td align="left">1002</td><td align="left">1105</td><td align="left">ForGlob1002</td><td align="left">1105ForGlob1002</td><td align="left">1105ForGlob1002</td></tr><tr><td style="background-color: rgb(202, 202, 202);" align="middle">16</td><td align="left">1105ForGlob1003</td><td align="left">1003</td><td align="left">1003</td><td align="left">1105</td><td align="left">ForGlob1003</td><td align="left">1105ForGlob1003</td><td align="left">1105ForGlob1003</td></tr><tr><td style="background-color: rgb(202, 202, 202);" align="middle">17</td><td align="left">1105ForGlob1003</td><td align="left">1003</td><td align="left">1003</td><td align="left">1105</td><td align="left">ForGlob1003</td><td align="left">1105ForGlob1003</td><td align="left">1105ForGlob1003</td></tr></tbody></table>
<table valign="middle" colspan="2" style="table-layout: auto; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: Calibri; font-size: 10px;" border="3" cellpadding="2" cellspacing="0"><colgroup><col width="40pt"><col></colgroup><tbody><tr style="background-color: rgb(238, 170, 170);"><td>Cell</td><td>Formula</td></tr><tr><td>B1</td><td>{=RIGHT(A1,COUNT(RIGHT(A1,COLUMN(1:1))*1))}</td></tr><tr><td>C1</td><td>=TEXT(B1,"0000")</td></tr><tr><td>D1</td><td>=LEFT(A1,4)</td></tr><tr><td>E1</td><td>=SUBSTITUTE(MID(A1,5,9^9),B1,C1)</td></tr><tr><td>F1</td><td>=D1&E1</td></tr><tr><td>G1</td><td>{=LEFT(A1,4)&SUBSTITUTE(MID(A1,5,9^9),RIGHT(A1,COUNT(RIGHT(A1,COLUMN(1:1))*1)),TEXT(RIGHT(A1,COUNT(RIGHT(A1,COLUMN(1:1))*1)),"0000"))}</td></tr></tbody></table><table style="font-family: Arial; font-size: 8pt; background-color: rgb(255, 255, 255);"><tbody><tr><td style="font-weight: bold;">Contains array formula!
</td></tr><tr><td>Do not enter the curly brackets {}.</td></tr><tr><td>Enter the formula with CTRL-SHIFT-ENTER instead of just ENTER.</td></tr></tbody></table><table style="font-family: Arial; font-size: 7pt;"><tbody><tr><td style="color: rgb(51, 51, 51);">Created with Tab2HTML (v2.4.1). ©Gerd alias Bamberg</td></tr></tbody></table>
 
Upvote 0
Hi Jim,

I'm probably way out again with this, but I'm finding it interesting to try and resolve this!

Before sorting....


Excel Workbook
DE
21105ForGlob109715
31105ForGlob109915
41105ForGlob1113
51105ForGlob1113
61105ForGlob11014
71105ForGlob110015
81105ForGlob110115
91105ForGlob110215
101105ForGlob110315
111105ForGlob110315
121105ForGlob110515
131105ForGlob110515
141105ForGlob110715
151105ForGlob110815
161105ForGlob110915
171105ForGlob11114
181105ForGlob111015
191105ForGlob111015
Sheet4



After sorting


Excel Workbook
DE
21105ForGlob1113
31105ForGlob1113
41105ForGlob11014
51105ForGlob11114
61105ForGlob109715
71105ForGlob109915
81105ForGlob110015
91105ForGlob110115
101105ForGlob110215
111105ForGlob110315
121105ForGlob110315
131105ForGlob110515
141105ForGlob110515
151105ForGlob110715
161105ForGlob110815
171105ForGlob110915
181105ForGlob111015
191105ForGlob111015
Sheet4


If this is incorrect, can you provide a sample of what you want after sorting please

Where can I get a complete list from?

Ak
 
Upvote 0
Ak,

I'm afraid I've taken the easy way out. ;(

I did a Find (1105ForGlob) and replaced with 110599. Then did a Find (1104Fort) and replaced with 1104 rendering the correctly ordered result BELOW -

BTW: I added the 99 so I could keep ForGlob and Fort results separate. "1104Fort" represented Fortune 1000 companies imported April 2011
"1105ForGlob" represented Forbes Global as of, well, May 2011.

Thanks - I will check back but, arrays and such (I think) are beyond my ability and, maybe, my need.

Just an aside: Is there any possibility that my sort "issues" were as a result of number not being saved as a number? Worse, I think the Forbes numbers may have been TEXT and the Fortune numbers as numbers. Just wondering?

Thanks again,Jim

11051993
11051994
11051995
11051995
11051997
11051997
11051999
11052000
100499006
100499013
100499034
100499042
100499049
100499049
100499059
100499064
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,291
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top