Solved

excel part number sort

Posted on 2010-11-29
5
381 Views
Last Modified: 2012-06-22
How do I get excel to sort part numbers so I can find my part number grouped together well.  
I need all the part numbers with 1 to show together even if its 100, 1234,1000, or 10000?

For example:
100
200
1234
1000
2000
10000
20000
200000
100000
0
Comment
Question by:rembury
5 Comments
 
LVL 58

Expert Comment

by:cyberkiwi
ID: 34232009
I those are "part numbers" (text), you should be storing them as text, by adding ' in front of them
Then they will sort as text (1's together).
For now, you can add a new column, and type this formula (If first is A1, and new column is B)
B1:  =TEXT(A1)
Copy down
Then select all your data, and sort by the new column
When Excel prompts (Sort Warning), choose the lower one (sort numbers and text separately)
0
 
LVL 24

Expert Comment

by:StephenJR
ID: 34232017
You could use =LEFT(A1,1) in the next column and sort by that one.
0
 
LVL 58

Accepted Solution

by:
cyberkiwi earned 500 total points
ID: 34232080
I meant

B1:  =TEXT(A1, "@")
...

But Stephen's LEFT does the same
0
 
LVL 12

Expert Comment

by:sstampf
ID: 34232115
You can also use the attached macro. Just select the range which you want to sort and then run this macro. You can also assign a shortcut key to it.

Regards
Shashank
Sub test()

Dim rng As Range, rng2 As Range

Set rng = Intersect(Selection, ActiveSheet.UsedRange)

For Each rng2 In rng

rng2.Value = "x" & rng2.Value

Next rng2

    ActiveSheet.Sort.SortFields.Clear

    ActiveSheet.Sort.SortFields.Add Key:=rng, _

        SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal

    With ActiveSheet.Sort

        .SetRange rng

        .Header = xlGuess

        .MatchCase = False

        .Orientation = xlTopToBottom

        .SortMethod = xlPinYin

        .Apply

    End With

For Each rng2 In rng

rng2.Value = Right(rng2.Value, Len(rng2.Value) - 1)

Next rng2

End Sub

Open in new window

0
 

Author Closing Comment

by:rembury
ID: 34232319
This worked great and was easy to use.

Thank-you
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now