Hi, Just formatting a cell as number after the cell has received data, does not change the format of the data.
If all your data is numeric, then follow these steps to actually change your data to numbers: 1. Select Range A71:A1000 2. Format as number. 3. Enter 1 into an unused cell, then right-click that cell, and select Copy. 4. Select Range A71:A1000, then right-click and select Paste Special. 5. Select Multiply from the Operation options. 6. Click OK. Now run your macro again, and it should sort as you want. If your data is a mix of numbers and letters, eg 1234ABCD, then the operation is more complex, but still possible. Regards - Dave. > Date: Thu, 23 Oct 2008 02:36:27 -0700 > Subject: $$Excel-Macros$$ Sorting a column > From: [EMAIL PROTECTED] > To: excel-macros@googlegroups.com > > > Hi All > > I'm trying to code a worksheet so that when I press a button, it sorts > the column in numerical order. I have been using the code > > Private Sub commandbutton12_click() > Range("A71:U1000").Select > Selection.Sort Key1:=Range("A71"), Order1:=xlAscending, > Header:=xlNo, _ > OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom > Range("A2").Select > Call CommandButton1_Click > End Sub > > However, whether the cells are formatted as numbers, general or text, > the numbers sort in the following manner > > 1 > 10 > 2 > 20 etc > > rather than > > 1 > 2 > 10 > 20etc > > How can I sort them as per the second manner please? > > Many thanks in advance > > > _________________________________________________________________ --~--~---------~--~----~------------~-------~--~----~ Visit the blog to download Excel tutorials at http://www.excel-macros.blogspot.com To post to this group, send email to excel-macros@googlegroups.com For more options, visit this group at http://groups.google.com/group/excel-macros?hl=en Visit & Join Our Orkut Community at http://www.orkut.com/Community.aspx?cmm=22913620 Visit the blog to download Excel tutorials at http://www.excel-macros.blogspot.com To Learn VBA Macros Please visit http://www.vbamacros.blogspot.com To see the Daily Excel Tips, Go to: http://exceldailytip.blogspot.com -~----------~----~----~----~------~----~------~--~---