Custom sort order

Jake975

Board Regular
Joined
Feb 9, 2020
Messages
114
Office Version
  1. 2016
Platform
  1. Windows
How do I use VBA to sort a list of file paths in this order here?
Title Page, Daily Cash Deposit Log, Journal by Cashier and Transaction Code, Manager Report, New Trial Balance, Trial Balance, CC History , Night Audit CC Authorization, Credit Limit all payment types, Open Balances All, Market Code Statistics, Deposit Ledger, Rate Variance , Detailed Aging , A/R Settlement , Guest by Tax Type, Guest Trial Balance , Guest Ledger Detail, Guest Ledger, Cashier Audit, Guests in House Comp, Out of Order, Paid Outs, Adjustment Log

Here is an example of the file paths for the names listed above:

C:\Users\Example\Desktop\02-16-2020\Adjustment Logtest.pdf
C:\Users\Example\Desktop\02-16-2020\AR Settlement.pdf
C:\Users\Example\Desktop\02-16-2020\Cashier Audit.pdf
C:\Users\Example\Desktop\02-16-2020\Credit Card History.pdf
C:\Users\Example\Desktop\02-16-2020\Credit Limit alltypes.pdf
C:\Users\Example\Desktop\02-16-2020\Deposit Ledger.pdf
C:\Users\Example\Desktop\02-16-2020\Detailed Aging.pdf
C:\Users\Example\Desktop\02-16-2020\Guest by Tax.pdf
C:\Users\Example\Desktop\02-16-2020\Guest COMP.pdf
C:\Users\Example\Desktop\02-16-2020\Guest Ledger Detail.pdf
C:\Users\Example\Desktop\02-16-2020\Guest Ledger.pdf
C:\Users\Example\Desktop\02-16-2020\Guest Trial Balance.pdf
C:\Users\Example\Desktop\02-16-2020\Journal by TRA.pdf
C:\Users\Example\Desktop\02-16-2020\Manager Report.pdf
C:\Users\Example\Desktop\02-16-2020\Market Code.pdf
C:\Users\Example\Desktop\02-16-2020\New Trial Balance.pdf
C:\Users\Example\Desktop\02-16-2020\Night Auth.pdf
C:\Users\Example\Desktop\02-16-2020\Open Balance.pdf
C:\Users\Example\Desktop\02-16-2020\Out of Order.pdf
C:\Users\Example\Desktop\02-16-2020\Paid Out.pdf
C:\Users\Example\Desktop\02-16-2020\Rate Variance.pdf
C:\Users\Example\Desktop\02-16-2020\RM222.pdf
C:\Users\Example\Desktop\02-16-2020\Title.pdf
C:\Users\Example\Desktop\02-16-2020\Trial Balance.pdf

Im not sure how to get it to sort in the order needed as i cant use alphabetical like normal and it should always list in that order.
Any help would be great thank you
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Is it an option to use a number prefix for the file names? I think that's the only way to enforce your own desired order, both in Windows Explorer and in producing a file list.
 
Upvote 0
Is your sample data accurate? A large proportion of the file paths do not match your stated list. There are many more but below I have highlighted some that I am guessing you want matched, but they don't actually match which would make the task doubly hard if it is a true reflection of your requirement.



How do I use VBA to sort a list of file paths in this order here?
Title Page, Daily Cash Deposit Log, Journal by Cashier and Transaction Code, Manager Report, New Trial Balance, Trial Balance, CC History , Night Audit CC Authorization, Credit Limit all payment types, Open Balances All, Market Code Statistics, Deposit Ledger, Rate Variance , Detailed Aging , A/R Settlement , Guest by Tax Type, Guest Trial Balance , Guest Ledger Detail, Guest Ledger, Cashier Audit, Guests in House Comp, Out of Order, Paid Outs, Adjustment Log

Here is an example of the file paths for the names listed above:

C:\Users\Example\Desktop\02-16-2020\Adjustment Logtest.pdf
C:\Users\Example\Desktop\02-16-2020\AR Settlement.pdf
C:\Users\Example\Desktop\02-16-2020\Cashier Audit.pdf
C:\Users\Example\Desktop\02-16-2020\Credit Card History.pdf
C:\Users\Example\Desktop\02-16-2020\Credit Limit alltypes.pdf
C:\Users\Example\Desktop\02-16-2020\Deposit Ledger.pdf
C:\Users\Example\Desktop\02-16-2020\Detailed Aging.pdf
C:\Users\Example\Desktop\02-16-2020\Guest by Tax.pdf
C:\Users\Example\Desktop\02-16-2020\Guest COMP.pdf
C:\Users\Example\Desktop\02-16-2020\Guest Ledger Detail.pdf
C:\Users\Example\Desktop\02-16-2020\Guest Ledger.pdf
C:\Users\Example\Desktop\02-16-2020\Guest Trial Balance.pdf
C:\Users\Example\Desktop\02-16-2020\Journal by TRA.pdf
C:\Users\Example\Desktop\02-16-2020\Manager Report.pdf
C:\Users\Example\Desktop\02-16-2020\Market Code.pdf
C:\Users\Example\Desktop\02-16-2020\New Trial Balance.pdf
C:\Users\Example\Desktop\02-16-2020\Night Auth.pdf
C:\Users\Example\Desktop\02-16-2020\Open Balance.pdf
C:\Users\Example\Desktop\02-16-2020\Out of Order.pdf
C:\Users\Example\Desktop\02-16-2020\Paid Out.pdf
C:\Users\Example\Desktop\02-16-2020\Rate Variance.pdf
C:\Users\Example\Desktop\02-16-2020\RM222.pdf
C:\Users\Example\Desktop\02-16-2020\Title.pdf
C:\Users\Example\Desktop\02-16-2020\Trial Balance.pdf
 
Upvote 0

Forum statistics

Threads
1,213,537
Messages
6,114,216
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top