Sorting Numbers with Multiple Decimals

I am attempting to create a file system using excel that can be easily 
searched and sorted by a number ie 1.3.12 or alphabetically.  At this time I 
have entered the data as I would like it to appear if sorted by number, 
however if I attempt to alphabetize I can not restore the numbers to their 
proper order.

Currently I have only 3 columns.  One with numbers, one with file names, and 
one with additional information.

For example

1	Office
1.1	Employees
1.1.1	Bob	Marketing
1.1.2	Dave	IT
…
1.1.12	Joe	Marketing
1.2	Equipment
1.2.1	Computers
….
12	Locations
12.1	USA
12.1.1	New York
12.1.1.1	New York	Primary
12.2	New Mexico
12.2.1	Albuquerque	Primary
…
12.2.15	California
12.2.15.1	L.A.	Secondary
…

Is there any way I can sort these alphabetically using the other two columns 
and then get back to the proper numbering?  A question that seems to be 
similar or related to this can be found here: 
http://www.excelforum.com/showthread.php?threadid=401416

Thanks,
-Ian

0
ian (162)
9/14/2005 11:22:02 PM
excel.misc 78881 articles. 5 followers. Follow

4 Replies
982 Views

Similar Articles

[PageSpeed] 3

So you want to get your data back into the original order?

If yes, insert a few columns to the right of the number column.

Then select that column
Data|Text to columns
delimited
by a dot
General for each field

Now you can sort your data by those helper columns---

Or you could insert one more column and use a formula like:
=text(d1,"000.")&text(e1,"000.")&text(f1,"000.")&text(g1,"000")
or maybe
=SUBSTITUTE(TRIM(IF(D1="","",TEXT(D1,"000 "))&IF(E1="","",TEXT(E1,"000 "))
  &IF(F1="","",TEXT(F1,"000 "))&IF(G1="","",TEXT(G1,"000 ")))," ",".")

(Then the dots will look nice.)

Then your outlining numbers will look like:

001.001.012.001

If you convert this column of formulas to values (edit|copy, edit|paste
special|values), you'll be able to sort it nicely.



Intern Ian wrote:
> 
> I am attempting to create a file system using excel that can be easily
> searched and sorted by a number ie 1.3.12 or alphabetically.  At this time I
> have entered the data as I would like it to appear if sorted by number,
> however if I attempt to alphabetize I can not restore the numbers to their
> proper order.
> 
> Currently I have only 3 columns.  One with numbers, one with file names, and
> one with additional information.
> 
> For example
> 
> 1       Office
> 1.1     Employees
> 1.1.1   Bob     Marketing
> 1.1.2   Dave    IT
> …
> 1.1.12  Joe     Marketing
> 1.2     Equipment
> 1.2.1   Computers
> ….
> 12      Locations
> 12.1    USA
> 12.1.1  New York
> 12.1.1.1        New York        Primary
> 12.2    New Mexico
> 12.2.1  Albuquerque     Primary
> …
> 12.2.15 California
> 12.2.15.1       L.A.    Secondary
> …
> 
> Is there any way I can sort these alphabetically using the other two columns
> and then get back to the proper numbering?  A question that seems to be
> similar or related to this can be found here:
> http://www.excelforum.com/showthread.php?threadid=401416
> 
> Thanks,
> -Ian

-- 

Dave Peterson
0
petersod (12004)
9/15/2005 12:32:47 AM
Hi Ian,

Have a look at my spreadsheet sort_chapter.xls:
http://www.bplumhoff.de/software/sort_chapter.xls

HTH,
Bernd
0
Utf
9/15/2005 9:02:01 AM
On Wed, 14 Sep 2005 16:22:02 -0700, "Intern Ian" <Intern
Ian@discussions.microsoft.com> wrote:

>I am attempting to create a file system using excel that can be easily 
>searched and sorted by a number ie 1.3.12 or alphabetically.  At this time I 
>have entered the data as I would like it to appear if sorted by number, 
>however if I attempt to alphabetize I can not restore the numbers to their 
>proper order.
>
>Currently I have only 3 columns.  One with numbers, one with file names, and 
>one with additional information.
>
>For example
>
>1	Office
>1.1	Employees
>1.1.1	Bob	Marketing
>1.1.2	Dave	IT
>�
>1.1.12	Joe	Marketing
>1.2	Equipment
>1.2.1	Computers
>�.
>12	Locations
>12.1	USA
>12.1.1	New York
>12.1.1.1	New York	Primary
>12.2	New Mexico
>12.2.1	Albuquerque	Primary
>�
>12.2.15	California
>12.2.15.1	L.A.	Secondary
>�
>
>Is there any way I can sort these alphabetically using the other two columns 
>and then get back to the proper numbering?  A question that seems to be 
>similar or related to this can be found here: 
>http://www.excelforum.com/showthread.php?threadid=401416
>
>Thanks,
>-Ian

Although I'm sure this can be done with worksheet functions, I found it
relatively simple to do using a VBA UDF (user defined function).

The "trick" is to transform the outline number appropriately, so that when
sorted it will give you the result you want.  You then put that number in an
adjacent column to your table, and sort on that column.  When done, you can
delete the column.

To enter the UDF, <alt><F11> opens the VB editor.  Ensure your project is
highlighted in the project explorer window, then Insert/Module and paste the
code below into the window that opens.

Be sure to note the MaxNum constant which is the Maximum Number of outline
sublevels you might have.  In your example, you showed four, so that is what I
used. In addition, I have assumed that the maximum number of levels within each
sublevel is 99.

In a column adjacent to your table, enter the formula:
	=combine(cell_ref)  (where cell_ref is the outline number)
and copy/drag down as far as needed.

Then sort on this new column (ascending).

=================================
Function combine(rg As Range) As Double
Const dot As String = "."
Const NullString As String = ""
Const MaxLevels As Long = 4 'Maximum number of levels
Const MaxSubLevels = 99 'Maximum number of sublevels in each level; must be
10^x-1
Dim i As Long
Dim temp

temp = Split(rg.Text, dot)

For i = 0 To UBound(temp)
    combine = combine + temp(i) * 10 ^ (((MaxLevels - 1) - i) _
        * Log(MaxSubLevels + 1) / Log(10))
Next i

End Function
==================================

HTH,

--ron
0
ronrosenfeld (3122)
9/15/2005 7:14:50 PM
Unfortunately I don't really understand how to use Excel's Visual Basic 
function.  I have entered the code you provided into a Module and saved it, 
however I am still having trouble. 

1) I don’t think I understand what an outline number is.  Could you give me 
an example?  I have been entering something like this:  =combine(A2).

2) Regardless of what I put into the combine function, it says there is a 
syntax error and highlights the first line of code.

I am working with Microsoft Office Excel 2003 (11.6355.6408) SP1 if that 
makes any difference.

Also, I actually have up to 8 numbers separated by decimals, however I 
expect I can change that by simply changing “Const MaxLevels As Long = 4” to 
” =8” ?

Thank you very much for your help.


> To enter the UDF, <alt><F11> opens the VB editor.  Ensure your project is
> highlighted in the project explorer window, then Insert/Module and paste the
> code below into the window that opens.
> 
> Be sure to note the MaxNum constant which is the Maximum Number of outline
> sublevels you might have.  In your example, you showed four, so that is what I
> used. In addition, I have assumed that the maximum number of levels within each
> sublevel is 99.
> 
> In a column adjacent to your table, enter the formula:
> 	=combine(cell_ref)  (where cell_ref is the outline number)
> and copy/drag down as far as needed.
> 
> Then sort on this new column (ascending).
> 
> =================================
> Function combine(rg As Range) As Double
> Const dot As String = "."
> Const NullString As String = ""
> Const MaxLevels As Long = 4 'Maximum number of levels
> Const MaxSubLevels = 99 'Maximum number of sublevels in each level; must be
> 10^x-1
> Dim i As Long
> Dim temp
> 
> temp = Split(rg.Text, dot)
> 
> For i = 0 To UBound(temp)
>     combine = combine + temp(i) * 10 ^ (((MaxLevels - 1) - i) _
>         * Log(MaxSubLevels + 1) / Log(10))
> Next i
> 
> End Function
> ==================================
> 
> HTH,
> 
> --ron
>

0
InternIan (4)
9/16/2005 11:27:45 PM
Reply:

Similar Artilces:

Replacing the Numbers
In my report I want to replace the value of my text data to a word. Example: in my report the TextBox: is (loc) which the "1", "2", "3" these are the records in the tables. They print out on the reports as 1, 2, and 3. I want to change that to read 1=ED, 2=EU and 3=EZ. And blank, if the user leave it blank as "NONE" I hope that's clear Thanks Check out your more recent thread with the same question. -- Duane Hookom MS Access MVP "bladelock" <bladelock@discussions.microsoft.com> wrote in message news:1FB81F68-1733-4174-8D...

Where's the Sort by New Message option?
Not sure when the layout of the newsgroups changed but I can't seem to find the ability to sort by new message in a thread instead of sorting by just the original thread date. That was hugely helpful as I could follow along and see what threads were still active. If you're gonna hang around in the newsgroups (any newsgroups), you may want to start using a newsreader. Microsoft Outlook Express can do it for you. Saved from a previous post: You may want to connect to the ms newsserver directly: If you have Outlook Express installed, try clicking on these links (or copy and paste i...

Outlook 2002 Contact Phone Number Field Formatting
Why don't phone numbers entered in the phone number contact fields on Outlook 2002 automatically format to include the paren's and hyphens? If this is suppose to happen, what is the setting to make it happen? They do here and always have. What are you seeing? --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. After searching google.groups.com and finding no answer mike <michael.kelner@fmr.com> asked: | Why don't phone numbers entered in the phone number | contact fields on Outlook 2002 automatically format to | include th...

Sorting
Hi, is it possible to use variable for sorting? Something like: declare @sort varchar(10) SET @sort='column1 DESC' SELECT ROW_NUMBER() OVER (ORDER BY @sort)AS rowId, * FROM table Is dynamic SQL only option? Thank you, Simon On 15/04/2010 11:28, simon wrote: > Hi, > > is it possible to use variable for sorting? > > Something like: > > declare @sort varchar(10) > SET @sort='column1 DESC' > > SELECT ROW_NUMBER() OVER (ORDER BY @sort)AS rowId, * FROM table > > Is dynamic SQL only option? You can use CASE to he...

How to sort account list?
I'm using MS Money 2004 Small Business. In the account list, my accounts are catagorized by and in this order: - bank accounts - credit accounts - investment accounts - loans and liabilities - asset accounts TOTAL BALANCE In the above view, I cannot easily determine totals for assets and liabilities. The following view does this. - bank accounts - investment accounts - asset accounts SUBTOTAL -loans and liabilities SUBTOTAL TOTAL BALANCE How do I get the above view? Thanks, Brett I don't use Small Business. But you can run a Net Worth report to get total assets and ...

Row names will not move with sort
Each row in my summary table in Sheet1 is hyperlinked to a corresponding table in Sheet2 with additional details. I need to move the rows in my summary table (Sheet1) and preserve the links to and from the details tables (Sheet2). I found that I can move rows in Sheet1 with cut & insert and the hyperlinks are maintained. I can travel from a row in summary table (Sheet1) to details table (Sheet2) and back, even after the corresponding row (Sheet1) was moved. But if I sort the rows in Sheet1 the links from Sheet2 back to corresponding rows in Sheet1 lead to presorted locations. Apparen...

I want to format a number cell without the decimal and without ro.
I need to format the number cell so that it will still show the numbers after the decimal, but not show the decimal point at all. It must also display leading zeros, which is not a problem. I just need a way to strip the decimal from the number. If if needs to stay a number with the same value, I don't think you can do it. If you can change the value Just multiple the number by ten to the number of decimal places. If it can be text set up a new column and use =substitute(a1,".',"") "LAM" wrote: > I need to format the number cell so that it will sti...

Text to Number conversion
Hi all, Need some help. One of my main data for my job, is in Excel format. The problem lies with the cell format. All number being stored as text. I need to do error checking and then keep pressing C on the keyboard ( for converting to number ) . It took between 30 to 45 minutes pressing time before it finally completed. Is there any way to remove this "Pressing Job" as it really irritates me. I don't blame you ...... Following from Excel Help:- 1.. Select a blank cell that you know has the General number format.=20 2.. In the cell, type 1, and then press ENTER.=20 ...

Aligning data with varying decimal places
I have a column of cells in which the data include various numbers of decimal places. Is there a way to align the data vertically so that the decimals line up, without adding trailing zeroes? one way: Format/Cells/Number/Custom 0.??? In article <DD9B0C05-0A1D-4A5A-99F4-BB8030D9F7F2@microsoft.com>, edpaul <edpaul@discussions.microsoft.com> wrote: > I have a column of cells in which the data include various numbers of decimal > places. Is there a way to align the data vertically so that the decimals > line up, without adding trailing zeroes? ...

sorts not sorting
OK- Thanks to everyones help I now i have a list i can work with... but there are a few problems.... the zips are all 5 digit and now i have to sort them... the problem is, THEY WONT SORT CORRECTLY!!!!!!! The numbers are not in order... some are but a lot are not... is there anyway to fix this???? i need to sort them by zip code but cant seem to get them to do it correctly.. any ideas??? ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~ View and post usenet messages directly from http://www.ExcelForum.com/ You are going to be far better of...

import- number- sort?
I imported this data into a spread sheet- I tried to format it to number, but when I sort it- I get : 37.08 4.33 4.79 4.8 42.56 5.94 Whats up with this? Thanks Brent Hi Brent, Install the TrimAll macro, select the column and invoke the macro from Alt+F8 http://www.mvps.org/dmcritchie/excel/join.htm#trimall Directions to install and use a macro at http://www.mvps.org/dmcritchie/excel/getstarted.htm#havemacro I expect that you have spaces or CHAR(128) "Required Blank" characters in you data you can check is =LEN(A1) --- HTH, David...

sorting macro #3
I need to sort on 8 cells in a row and on 1500+rows. I can do it one at a time but I know there must be an easier way. Can ANYONE HELP? C3:J3 I need these cells sorted and then down to C1532:J1532 I did create a macro to sort after I selected them but still one at a time. Does it have to be a macro? I can edit a macro but don't really know how to program them. Yes, it has to be a macro. The following should do it. This macro loops through all the entries in Column C, and in each row it sorts the values in Columns C:J. HTH Otto Sub SortRows() Dim rColC As Range Dim i As...

Can we sort a form and also be able to enter new records.
Hi, It is possible to sort the data on a form and also be able to enter new and edit the existing records in it. Cheers! On Tue, 15 Jan 2008 15:41:16 -0800 (PST), Rex wrote: > Hi, > > It is possible to sort the data on a form and also be able to enter > new and edit the existing records in it. > > Cheers! I assume you mean "Is it". The form sort order has nothing to do with editing or adding new records, so the answer is yes. If you cannot edit or add new records, make sure the form's record source, if it is a query, is updateable. Some queries are not. O...

Sorting checking register
How do i sort my check register in Money 2004 Deluxe so that uncleared transactions appear below cleared transactions? In Quicken i could click on the column to provide that sort. In microsoft.public.money, Dean wrote: >How do i sort my check register in Money 2004 Deluxe so >that uncleared transactions appear below cleared >transactions? In Quicken i could click on the column to >provide that sort. You don't. Available choices are chosen by clicking View at the top of the register. ...

Is it possible to sequentially number the comments field
Anyone out there clever enough to tell me how to sequentially populate the comments field in cells... the problem I can see is that the cells are in a grid of A5-10 through to i5 to 10, I want them populating a5,a6,a7,a8,a9,a10,b5,b6 etc and when I get to i10 I want the sequence to carry over to the next sheet... Don't want much do I ;) TIA Nick It looks like rather than "sequentially" populating the Comment fields, you are simply putting the cell's address into the Comment field. If that observation is correct, then I do not know what you mean when you said "when ...

using addrress books to sort incoming mail
I use address books to sort incoming mail. An odd thing: depending on how the sender's name comes across, it doesn't get caught by the filter (amd moved to the "Family Mail" Folder I have set up. for example: my mom and dad's email (from momanddad@somedomain.com) comes as from that address. However, in my contacts, they are listed by their names: John and Mary Smith, with momanddad@somedomain.com as their email address and John and Mary Smith as the display name. What have I done wrong? TIA 1. The big ONE - failed to post your version of Outlook. Rules operate at ...

Reusing SBMnn Numbers and Locating SBM files
I have added and deleted various companies in SBM. Each add uses the next SBM number. When I delete a company that number is removed. Is there a way to recover and re-use a number? Is it possible to have different SBM companies on different drives? Fred Fred, Next newsgroup down. This is the M$ Retail Management Point of Sale group. -- * "Fred" <Fred@discussions.microsoft.com> wrote in message news:A2454A5E-956F-4EF1-BCDA-A5A4B8C0457B@microsoft.com... I have added and deleted various companies in SBM. Each add uses the next SBM number. When I delete a company that numbe...

Printing page numbers in report writer reports.
Dear All, Is there any way to print the page numbers in reports like 1 of 10, 2 of 10,...............10 of 10 format instead of 1,2,3,.................10. Any help would be greatly appreciated! Thanks! -- Developer Hi Habeeb Sadly this is not possible with the Dexterity Report Writer. The Report Writer is a single pass report writer which means it will not know how many pages are printed until it has printed them, by which time it is too late to put the "of #" on the page. If you used VBA with RetrieveGlobals.dll. ADO and SQL to access the tables and estimate the numbe...

Entities with Multiple Entries - or Campaigns?
I hope someone out there will be kind enough to help me with this dilemma. Sorry this is lengthy but hopefully the description will make it easier to offer assistance. :-) We do a number of "marketing events" to which we invite clients and prospects. I've been reading a number of posts and thought I would be brilliant and create a new entity called "Marketing Events." In my dream I thought I would be able to create a list of events on one screen, then within contacts I would be able to select an event that a person had attended. Again, in my dream, I had th...

how do i print multiple copies of a sheet of labels?
In Publisher 2007 we can set the number of copies of a label per sheet of paper. How can I set the nuber of pieces of paper? In other words I have a label that prints 30 to a page. How can I print 20 pages? We use this to print multiple addres labels for our booklets. Thanks, Joe joegat2000 wrote: > In Publisher 2007 we can set the number of copies of a label per > sheet of paper. How can I set the nuber of pieces of paper? > > In other words I have a label that prints 30 to a page. How can I > print 20 pages? We use this to print multiple addres labels for our > booklets...

Unmerge so I can sort
I coy/pasted data into Excell and when I try to sort it I get "This operation requires merged sells to be identically sized". I understadn the work around in KB but how do I find which sells are merged? I wouldn't bother looking. I'd just remove all the merged cells from the range to sort. Select that range format|cells|alignment tab uncheck the merge cells box But if you wanted to search, you can do it via process of elimination. Select a range, format|cells|alignment tab. If that merge cells box is checked, then the whole selection is merged. If it's grey, t...

How can I format the #of decimals, field types, etc. automaticall.
I am importing a delimited file, it can be a csv, tab delimted, doesn't matter, but I want it to come up in excel properly formatted to the # of decimal places each field is formatted with in the delimited file. I also want zip code to come in with a leading 0, not be interpreted as a number even though I have enclosed it in quotes. If you double click on a .csv file, excel will open it the way it wants. If you rename the file to .txt, you could see the import wizard and format each field as text--but that makes arithmetic a little more difficult. (I wouldn't do it this way.)...

sorting issue
Hi, When a range of columns are highlighted and a sort is performed on only one column empty cells above the sort display first. How can this be prevented. I know when there is data in any of the other column but not on the column being sorted this will happen. Any thoughts? Pat Are you sure the cells are really empty? They don't contain spaces or even formulas that evaluate to "". (Even formulas converted to values that returned "")? Pat wrote: > > Hi, > > When a range of columns are highlighted and a sort is performed on only one > column em...

Sort not sorting all rows
I'm using Excel 2000. have created a document, uploaded it to google docs and spreadsheets, exported it as a doc, converted it to a spreadsheet (excel) and uploaded it again to google docs. It's not a complicated file - no calculations or anything, just a simple log to enable us to collaborate on change requests and website faults. New requests are assigned a number incrementally one higher than the previous. So we need to sort on the Log number column to see what the last logged number was. However, it sorts most of the spreadsheet and leaves the same 5 rows unsorted at the...

Contact telephone number format keeps changing to a format I don't want
I want my telephone numbers in this format: +II-AA-NNN-NNNN where II is the international country code, AA is the area code and NNN-NNNN is the telephone number. When I edit a contact number it changes my format from +II-AA-NNN-NNNN to +II (AA) NNN-NNNN No matter what I do, I can't get rid of the parenthesis and the "-" symbol gets deleted around the area code number. Ideas on how to keep it the way I like it? Masking of phone numbers is hard coded. You can't configure it. -- Russ Valentine [MVP-Outlook] "��" <news@kidsnews.au.org> wrote in messag...