VBA sort with custom sort help

debmullin

New Member
Joined
May 3, 2019
Messages
3
Hello
I need help with code for a file to sort by 3 criteria, one custom. It is a schedule of classes. First sort is by room (column Y), second sort is Day(s) of classes and needs to be custom. Custom data is: MW, M, W, TR, T, R, F. This is column T. The 3rd criteria is start time of class. Column U and properties are time 1:30 pm. Row A is header column. Sort should be ascending for 1st and 3rd sort. @nd sort sb as in order it appears on my list. I am using range for my code. First sort code looks like this:

Worksheets("Area").Sort.SortFields.Clear
Sheets("area").Activate
Range("A1:AD700").Sort Key1:=Range("Y1"), Order1:=xlAscending, Header:=xlYes

I am a beginner so go gentle. I tried inserting key 2 as customorder and bombed out:
Key2:=Range("T1"), OrderCustom:=x

Anyone have a solution?

thanks
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
How about
VBA Code:
Sub debmullin()
   With Sheets("Area").Sort
      .SortFields.Clear
      .SortFields.Add Range("Y1"), , xlAscending
      .SortFields.Add Range("T1"), , , "MW, M, W, TR, T, R, F"
      .SortFields.Add Range("U1"), , xlAscending
      .SetRange Range("A1:AD700")
      .Header = xlYes
      .Apply
   End With
End Sub
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,847
Messages
6,121,911
Members
449,054
Latest member
luca142

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