Go Back   Trackpads Community > General Discussions > Computer and Technology > Microsoft Applications

Microsoft Applications Discussions about Windows and other MS Products such as Office

Reply
 
LinkBack Thread Tools
Old 06-16-2004, 00:41   #1 (permalink)
Rasoul Khoshravan Azar
Civilians

 
Default sort a column of numbers including minus numbers

Would like to sort a column of numbers including minus numbers.
However the result is odd. Numbers are sorted without considering the minu
sign. What is the problem.
Example:

0.41
3.58
5
0.17-
0.68-
0.75-
1.13-

but 5 should appear in top and then 3.58


 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Trackpads Information
Click to Visit
Old 06-16-2004, 00:41   #2 (permalink)
Frank Kabel
Civilians

 
Default Re: sort a column of numbers including minus numbers

Hi
probably your numbers are stored as text. Try converting them to
numbers:
- select your data
- goto 'data - Text in columns'
- go through this wizard and finish the wizard
- try your sorting again

--
Regards
Frank Kabel
Frankfurt, Germany


Rasoul Khoshravan Azar wrote:
> Would like to sort a column of numbers including minus numbers.
> However the result is odd. Numbers are sorted without considering the
> minu sign. What is the problem.
> Example:
>
> 0.41
> 3.58
> 5
> 0.17-
> 0.68-
> 0.75-
> 1.13-
>
> but 5 should appear in top and then 3.58


 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-16-2004, 00:41   #3 (permalink)
Gord Dibben
Civilians

 
Default Re: sort a column of numbers including minus numbers

Rashoul

I would move the minus sign to the left of the numbers.

If you have Excel 2002 you can do this by going to Data>Text to Columns>Fixed
Width>Next>Next and select the "Advanced" button. Checkmark in "trailing
minus for negative numbers" and Finish.

Now try your sort.

If you are using an earlier version of Excel you will need VBA to change the
signs.

Sub Negsignleft()
Dim cell As Range
Dim rng As Range
''move minus sign from right to left on entire worksheet
On Error Resume Next
Set rng = ActiveSheet.Cells. _
SpecialCells(xlCellTypeConstants, xlTextValues)
On Error GoTo 0
For Each cell In rng
If IsNumeric(cell.Value) Then
cell.Value = CDbl(cell.Value)
End If
Next cell
End Sub

Gord Dibben Excel MVP

On Sat, 27 Mar 2004 20:47:35 +0430, "Rasoul Khoshravan Azar"
<rasoulazar@hotmail.com> wrote:

>Would like to sort a column of numbers including minus numbers.
>However the result is odd. Numbers are sorted without considering the minu
>sign. What is the problem.
>Example:
>
> 0.41
> 3.58
> 5
> 0.17-
> 0.68-
> 0.75-
> 1.13-
>
> but 5 should appear in top and then 3.58
>


 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-16-2004, 00:41   #4 (permalink)
Rasoul Khoshravan Azar
Civilians

 
Default Re: sort a column of numbers including minus numbers

I am using 2000 ver of Excel.
But data are stored in cells as numbers not as texts.
I will try the VBA code you have sent. Thanks for that.
TIA
Rasoul

"Gord Dibben" <gorddibbATshawDOTca> wrote in message
news:s7cb60do4286ef8bgk0m0j9kquglnpm26i@4ax.com...
> Rashoul
>
> I would move the minus sign to the left of the numbers.
>
> If you have Excel 2002 you can do this by going to Data>Text to

Columns>Fixed
> Width>Next>Next and select the "Advanced" button. Checkmark in "trailing
> minus for negative numbers" and Finish.
>
> Now try your sort.
>
> If you are using an earlier version of Excel you will need VBA to change

the
> signs.
>
> Sub Negsignleft()
> Dim cell As Range
> Dim rng As Range
> ''move minus sign from right to left on entire worksheet
> On Error Resume Next
> Set rng = ActiveSheet.Cells. _
> SpecialCells(xlCellTypeConstants, xlTextValues)
> On Error GoTo 0
> For Each cell In rng
> If IsNumeric(cell.Value) Then
> cell.Value = CDbl(cell.Value)
> End If
> Next cell
> End Sub
>
> Gord Dibben Excel MVP
>
> On Sat, 27 Mar 2004 20:47:35 +0430, "Rasoul Khoshravan Azar"
> <rasoulazar@hotmail.com> wrote:
>
> >Would like to sort a column of numbers including minus numbers.
> >However the result is odd. Numbers are sorted without considering the

minu
> >sign. What is the problem.
> >Example:
> >
> > 0.41
> > 3.58
> > 5
> > 0.17-
> > 0.68-
> > 0.75-
> > 1.13-
> >
> > but 5 should appear in top and then 3.58
> >

>



 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-16-2004, 00:41   #5 (permalink)
David McRitchie
Civilians

 
Default Re: sort a column of numbers including minus numbers

Actually you may have formatted the column as number of
some kind but with a right minus you would find it is text
in your Excel 2000. =ISTEXT(A1) would show True so you would
need a macro such as Gord supplied or other means to convert
to a number. [ topic on my site is insrtrow.htm#fixrightminusown ]

"Rasoul Khoshravan Azar" <rasoulazar@hotmail.com> wrote ...
> I am using 2000 ver of Excel.
> But data are stored in cells as numbers not as texts.
> I will try the VBA code you have sent. Thanks for that.


> "Gord Dibben" <gorddibbATshawDOTca> wrote
> > I would move the minus sign to the left of the numbers.
> > [code provided was clipped]



 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-16-2004, 00:42   #6 (permalink)
Dave Hawley
Civilians

 
Default Re: sort a column of numbers including minus numbers

Hi Rasoul

If you prefer a formula approach, you can find one below. There is also
a macro.
http://www.ozgrid.com/Excel/excel-im...ve-numbers.htm

***** Posted via: http://www.ozgrid.com
Excel Templates, Training & Add-ins.
Free Excel Forum http://www.ozgrid.com/forum *****
 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-16-2004, 00:45   #7 (permalink)
Rasoul Khoshravan Azar
Civilians

 
Default Re: sort a column of numbers including minus numbers

Dear Dave
Thanks for the link, It solved my problem. It was very neat with good
explanation.

Regards
Rasoul

"Dave Hawley" <dave@ozgrid.com> wrote in message
news:4066389b$0$201$75868355@news.frii.net...
> Hi Rasoul
>
> If you prefer a formula approach, you can find one below. There is also
> a macro.
> http://www.ozgrid.com/Excel/excel-im...ve-numbers.htm
>
> ***** Posted via: http://www.ozgrid.com
> Excel Templates, Training & Add-ins.
> Free Excel Forum http://www.ozgrid.com/forum *****



 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
I want to sort, ignoring all characters except numbers wojo Microsoft Applications 8 07-08-2005 20:00
Formating a column of numbers Greg Scarff Microsoft Applications 2 04-19-2005 16:00
Adding Numbers on 1 Column based on the Value of another Column Jonas Magcase Microsoft Applications 3 06-16-2004 00:50
Sort a column of numbers Bill Fellows Microsoft Applications 2 06-16-2004 00:41
How to sort numbers last? Robert Microsoft Applications 2 06-15-2004 17:49


Community Information
Options
Quick Options
Trackpads Non-Commercial Ad
Copyright Information Click to Visit
Time
Server Time
All times are GMT -4. The time now is 11:18.
Copyright
Copyright Information
The header is based off of work by Vipixel.com and modified by this site. Trackpads and the Trackpads Logo are both Registered Trademarks of Jason Edwards and cannot be used without prior written permission.  The only exception is as a link back to this site. Trackpads is a private website run by a small legion of volunteers, 3 dogs, 12.5 cats and an army of small, super smart, bio-engineered mice with pointy hats and tutu's. Search Engine Friendly URLs by vBSEO 3.2.0 RC7
Archive Links
Archive Links
Page generated in 0.83447 seconds with 19 queries