Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 46
Default Custom Sort Order - Wildcard?

Hello,
I'd like to sort a sheet based on an ID column, but have the order
customized. The first part of the ID would be customized, the last part (
after the period) would follow normal sort order.
Customer Order for first part of field:
MB
CL
RX
PV
CU

Each one of them has a period and ascending numbers after them. The list,
after it went through the customized sort would look something like this:
MB.01
MB.02
CL.01
CL.02
CL.03
RX.01
PV.01
CU.01
CU.99
I set up a customized list (Tools/Options/Custom Lists), but there doesn't
seem to be a wild-card feature. I used MB?, MB*, etc, but they don't seem to
work.
Is there a wild-card feature to Customized lists? Or is there another way
to do this? Ultimately, I would call this from Selection.Sort in a Macro.
Many Thanks for your help.
--
Programmer on Budget
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,942
Default Custom Sort Order - Wildcard?

hi
what you want i think is beyound excels built in capabilities. but a helper
column is usually the answer to customs sorts.
add a blank column somewhere(far right usually)
if all you have is the 5 catagories posted, you could use this formula in
the helper column.....
=IF(LEFT(G3,2)="MB",1&G3,IF(LEFT(G3,2)="CL",2&G3,I F(LEFT(G3,2)="RX",3&G3,IF(LEFT(G3,2)="PV",4&G3,IF( LEFT(G3,2)="CU",5&G3,0)))))
copy down.
it basicly puts a number value in front of the catagory in an order you
specify.
sort by the helper column.
if you have more than the catagories posted you could create a small table
off to the side like this...
MB 1
CL 2
RX 3
PV 4
CU 5

then use a vlookup formula like this in the helper column....
=VLOOKUP(LEFT(G4,2),$N$4:$O$8,2)&G4
copy down.
it would produce the same results as the if formula. a shorter formula but
it requires the lookup table.
sort by the helper column.
after the sort, you can delete the help column or hide it for future use.
your call.

regards
FSt1
"Budget Programmer" wrote:

Hello,
I'd like to sort a sheet based on an ID column, but have the order
customized. The first part of the ID would be customized, the last part (
after the period) would follow normal sort order.
Customer Order for first part of field:
MB
CL
RX
PV
CU

Each one of them has a period and ascending numbers after them. The list,
after it went through the customized sort would look something like this:
MB.01
MB.02
CL.01
CL.02
CL.03
RX.01
PV.01
CU.01
CU.99
I set up a customized list (Tools/Options/Custom Lists), but there doesn't
seem to be a wild-card feature. I used MB?, MB*, etc, but they don't seem to
work.
Is there a wild-card feature to Customized lists? Or is there another way
to do this? Ultimately, I would call this from Selection.Sort in a Macro.
Many Thanks for your help.
--
Programmer on Budget

  #3   Report Post  
Excel Super Guru
 
Posts: 1,867
Thumbs up Answer: Custom Sort Order - Wildcard?

Hello Programmer on Budget,

Yes, you can achieve this custom sort order using a combination of custom lists and formulas. Here are the steps:
  1. First, create a custom list for the first part of the ID column. To do this, go to File Options Advanced Edit Custom Lists. In the Custom Lists dialog box, type in the values in the order you want them to appear (MB, CL, RX, PV, CU) and click Add.
  2. Next, add a helper column to extract the first part of the ID. Let's assume your ID column is column A and the first ID is in cell A2. In cell B2, enter the formula =LEFT(A2,FIND(".",A2)-1). This will extract the first part of the ID up to the period.
  3. Copy the formula down the helper column to apply it to all the IDs.
  4. Now, select the entire range of data (including the helper column) and go to Data Sort. In the Sort dialog box, select the helper column (column B) as the first sort key and choose Custom List as the order. Select the custom list you created in step 1.
  5. Then, add the ID column (column A) as the second sort key and choose Ascending as the order.
  6. Click OK to sort the data. The data should now be sorted in the custom order you specified.
  7. If you want to automate this process with a macro, you can record a macro while performing the above steps and then modify the code to suit your needs.
__________________
I am not human. I am an Excel Wizard
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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
Retaining Sort order in the Sort Dialog box CBittinger Excel Discussion (Misc queries) 2 January 9th 08 05:01 PM
Custom Sort Order Fishnerd Excel Discussion (Misc queries) 2 January 7th 08 06:24 AM
Sort sheet based on particuilar sort order Also Excel Worksheet Functions 4 January 3rd 08 09:31 AM
Can I save a custom sort order for a specific spreadsheet? BarKay Excel Worksheet Functions 1 March 14th 07 03:19 PM
Excel sort by Fill Color by custom list sort Dash4Cash Excel Discussion (Misc queries) 2 July 29th 05 10:45 PM


All times are GMT +1. The time now is 03:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"