Ok, I recorded a macro to sort a spreadsheet the way I need. That's the first code posted below. The issue is, I have 5 sheets that I want sorted the same way. I took a stab at coding for this, leveraging some other code that I have (2nd code set), but I'm getting an "Unable to Find Sort Property" error. I've googled and searched in this forum, but I'm not finding anything that shows how to abbreviate the code, to account for 5 worksheets.
Code:
Range("A1").Select Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
ActiveWorkbook.Worksheets("DC").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("DC").Sort.SortFields.Add Key:=Range("D2:D3"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("DC").Sort.SortFields.Add Key:=Range("B2:B3"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("DC").Sort
.SetRange Range("A1:T3")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Code:
Private Sub Workbook_Open()
Dim ws As Worksheet
For Each ws In Worksheets
If Not ws.Name = "Bios" Then
ws.Sort.SortFields.Clear
ws.Columns("A:T").Sort.SortFields.Add key1:=ws.Columns("D"), SortOn1:=xlSortOnValues, Order1:=xlAscending
ws.Columns("A:T").Sort.SortFields.Add key2:=ws.Columns("B"), SortOn2:=xlSortOnValues, Order2:=xlDescending
End If
Next ws
End Sub