Can you sort sort specific data in one column based on values from another column using VBA?

Indominus

Board Regular
Joined
Jul 11, 2020
Messages
160
Office Version
  1. 2016
Platform
  1. Windows
Hello. So I have this one workbook. It has arrival times in column A. Route codes in column B. And staging areas in column D. So a route code arrives at the time in column A and staged in the area in column D. I have many vba codes for this unique workbook. All route codes in column B start with "MX" except for a couple "MV" ones. Now I have been tasked with making sure these MV route codes are at the front of the wave for 12:00. 12:00 arrival time routes are staged in C. However, the file does not include the MV routes up top. How can I enter in a code that will identify the MV routes and make sure they are the first ones in the 12:00:00 wave? Thank you. Here is a screenshot showing the file and how the MV route codes are not up top.
 

Attachments

  • mv.JPG
    mv.JPG
    65.8 KB · Views: 14

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Just to get the ball rolling. Indominus I am not real sure what it is you want. But we have to start some place. I just sorted the 12:00 data. Now this will start the questions and discussion. Also if you could use this XL2BB

Before Sort
Book1
ABCDE
1Arrival TimesRoute CodesRoute StagedStaging Area
211:40:00MX117772608-1STG.B29HORI
311:40:00MX119772608-1STG.B30HORI
411:40:00MX114772608-1STG.B31HORI
511:40:00MX113772608-1STG.B32HORI
612:00:00MV1772608-1STG.C01RDLT
712:00:00MX93772608-9STG.C02RDLT
812:00:00MX12772608-1STG.C03RDLT
912:00:00MX11772608-1STG.C04RDLT
1012:00:00MX42772608-4STG.C05RDLT
1112:00:00MX43772608-4STG.C06RDLT
1212:00:00MX62772608-6STG.C07RDLT
1312:00:00MX141772608-1STG.C08RDLT
1412:00:00MX68772608-6STG.C09RDLT
1512:00:00MX69772608-6STG.C10RDLT
1612:00:00MV2772608-2STG.C11RDLT
1712:00:00MX57772608-5STG.C12RDLT
1812:00:00MX58772608-5STG.C13RDLT
Before Sort


After Sort
Book1
ABCDE
1Arrival TimesRoute CodesRoute StagedStaging Area
211:40:00MX117772608-1STG.B29HORI
311:40:00MX119772608-1STG.B30HORI
411:40:00MX114772608-1STG.B31HORI
511:40:00MX113772608-1STG.B32HORI
612:00:00MV1772608-1STG.C01RDLT
712:00:00MV2772608-2STG.C11RDLT
812:00:00MX11772608-1STG.C04RDLT
912:00:00MX12772608-1STG.C03RDLT
1012:00:00MX141772608-1STG.C08RDLT
1112:00:00MX42772608-4STG.C05RDLT
1212:00:00MX43772608-4STG.C06RDLT
1312:00:00MX57772608-5STG.C12RDLT
1412:00:00MX58772608-5STG.C13RDLT
1512:00:00MX62772608-6STG.C07RDLT
1612:00:00MX68772608-6STG.C09RDLT
1712:00:00MX69772608-6STG.C10RDLT
1812:00:00MX93772608-9STG.C02RDLT
After Sort
 
Upvote 0
Just to get the ball rolling. Indominus I am not real sure what it is you want. But we have to start some place. I just sorted the 12:00 data. Now this will start the questions and discussion. Also if you could use this XL2BB

Before Sort
Book1
ABCDE
1Arrival TimesRoute CodesRoute StagedStaging Area
211:40:00MX117772608-1STG.B29HORI
311:40:00MX119772608-1STG.B30HORI
411:40:00MX114772608-1STG.B31HORI
511:40:00MX113772608-1STG.B32HORI
612:00:00MV1772608-1STG.C01RDLT
712:00:00MX93772608-9STG.C02RDLT
812:00:00MX12772608-1STG.C03RDLT
912:00:00MX11772608-1STG.C04RDLT
1012:00:00MX42772608-4STG.C05RDLT
1112:00:00MX43772608-4STG.C06RDLT
1212:00:00MX62772608-6STG.C07RDLT
1312:00:00MX141772608-1STG.C08RDLT
1412:00:00MX68772608-6STG.C09RDLT
1512:00:00MX69772608-6STG.C10RDLT
1612:00:00MV2772608-2STG.C11RDLT
1712:00:00MX57772608-5STG.C12RDLT
1812:00:00MX58772608-5STG.C13RDLT
Before Sort


After Sort
Book1
ABCDE
1Arrival TimesRoute CodesRoute StagedStaging Area
211:40:00MX117772608-1STG.B29HORI
311:40:00MX119772608-1STG.B30HORI
411:40:00MX114772608-1STG.B31HORI
511:40:00MX113772608-1STG.B32HORI
612:00:00MV1772608-1STG.C01RDLT
712:00:00MV2772608-2STG.C11RDLT
812:00:00MX11772608-1STG.C04RDLT
912:00:00MX12772608-1STG.C03RDLT
1012:00:00MX141772608-1STG.C08RDLT
1112:00:00MX42772608-4STG.C05RDLT
1212:00:00MX43772608-4STG.C06RDLT
1312:00:00MX57772608-5STG.C12RDLT
1412:00:00MX58772608-5STG.C13RDLT
1512:00:00MX62772608-6STG.C07RDLT
1612:00:00MX68772608-6STG.C09RDLT
1712:00:00MX69772608-6STG.C10RDLT
1812:00:00MX93772608-9STG.C02RDLT
After Sort

Hello. So this is basically what I want. MV route codes on top of the 12:00:00 wave. However I do not want to sort all column B since their staging areas are associated with papers we print out. Since I have to make the staging areas in order after (C01, C02, C03, etc). Only want to move the MV route codes. For example in your example MV2 would be STG.C02
 
Upvote 0
One more time. I only sorted columns A, B & C.

20-09-22 Rev A.xlsx
ABCDE
1Arrival TimesRoute CodesRoute StagedStaging Area
211:40:00MX117772608-1STG.B29HORI
311:40:00MX119772608-1STG.B30HORI
411:40:00MX114772608-1STG.B31HORI
511:40:00MX113772608-1STG.B32HORI
612:00:00MV1772608-1STG.C01RDLT
712:00:00MV2772608-2STG.C02RDLT
812:00:00MX11772608-1STG.C03RDLT
912:00:00MX12772608-1STG.C04RDLT
1012:00:00MX141772608-1STG.C05RDLT
1112:00:00MX42772608-4STG.C06RDLT
1212:00:00MX43772608-4STG.C07RDLT
1312:00:00MX57772608-5STG.C08RDLT
1412:00:00MX58772608-5STG.C09RDLT
1512:00:00MX62772608-6STG.C10RDLT
1612:00:00MX68772608-6STG.C11RDLT
1712:00:00MX69772608-6STG.C12RDLT
1812:00:00MX93772608-9STG.C13RDLT
After Sort
 
Upvote 0

Forum statistics

Threads
1,214,426
Messages
6,119,411
Members
448,894
Latest member
spenstar

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