Basically, I want to sort an array (A1:EZ13000) using 48 different sort criteria in a macro. Note, the 48 sort criteria are grouped into 8 groups of 6, and only one of those six will be used in a particular analysis (sort of the data). I have tried to make the following code work. Would someone be able to assist please.
Thanks in anticipation.

Thanks in anticipation.
Code:
Sub M6SortAndFilterSavedSets()
'
' M6 Sort And Filter Saved Sets Macro
' Macro recorded 26/08/2006 by mxman
If Sheets("Saved Sets").Range("G6") = Sheets("Report").Range("P9") Then
GoTo Section2
Else
Sheets("Report").Range("J17:FI17").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Saved Sets").Select
Range("A14").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Section2:
'Firstly, ensure that all the data is there ready and accessible for filtering
'(do so by doing an arbitary filtering process and then doing a "ShowAllData"
'process (to bring everything back, including data that may have been hidden).
Sheets("Saved Sets").Select
Range("A13:EZ13").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
Range("L3:L4"), Unique:=False
Sheets("Saved Sets").Select
Range("A13").Select
ActiveSheet.ShowAllData
'Secondly, sort all the data in accordance with the requested sort order.
Dim SortNumber As Integer 'ie:- the number of sort criteria to be applied.
SortNumber = Sheets("Report").Range("H43").Value
Dim FirstSort As String
FirstSort = Sheets("Report").Range("I49").Value
Dim FirstSortRange As Range
Set FirstSortRange = Range("I49").Value
Dim SecondSort As String
SecondSort = Range("I50").Value
Dim SecondSortRange As Range
Set SecondSortRange = Range("I50").Value
Dim ThirdSort As String
ThirdSort = Range("I51").Value
' Dim ThirdSortRange As Range
' Set ThirdSortRange = Range("ThirdSort")
Dim FourthSort As String
FourthSort = Range("I52").Value
' Dim FourthSortRange As Range
' Set FourthSortRange = Range("FourthSort")
Dim FifthSort As String
FifthSort = Range("I53").Value
' Dim FifthSortRange As Range
' Set FifthSortRange = Range("FifthSort")
Dim SixthSort As String
SixthSort = Range("I54").Value
' Dim SixthSortRange As Range
' Set SixthSortRange = Range("SixthSort")
Dim SeventhSort As String
SeventhSort = Range("I55").Value
' Dim SeventhSortRange As Range
' Set SortRange = Range("SeventhSort")
Dim EighthSort As String
EighthSort = Range("I56").Value
' Dim EighthSortRange As Range
' Set EighthSortRange = Range("EighthSort")
If SortNumber = 1 Then
Sheets("Saved Sets").Select
Range("A13:EZ13").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Sort Key1:=FirstSort, Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
ElseIf SortNumber = 2 Then
Sheets("Saved Sets").Select
Range("A13:EZ13").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Sort Key1:=FirstSort, Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Selection.Sort Key2:=SecondSort, Order2:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption2:=xlSortNormal
ElseIf SortNumber = 3 Then
Sheets("Saved Sets").Select
Range("A13:EZ13").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Sort Key1:=Range("I49").Value, Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Selection.Sort Key1:=Range("I50").Value, Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Selection.Sort Key1:=Range("I51").Value, Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
ElseIf SortNumber = 4 Then
Sheets("Saved Sets").Select
Range("A13:EZ13").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Sort Key1:=Range("I49").Value, Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Selection.Sort Key1:=Range("I50").Value, Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Selection.Sort Key1:=Range("I51").Value, Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Selection.Sort Key1:=Range("I52").Value, Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
ElseIf SortNumber = 5 Then
Sheets("Saved Sets").Select
Range("A13:EZ13").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Sort Key1:=Range("I49").Value, Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Selection.Sort Key1:=Range("I50").Value, Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Selection.Sort Key1:=Range("I51").Value, Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Selection.Sort Key1:=Range("I52").Value, Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Selection.Sort Key1:=Range("I53").Value, Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
ElseIf SortNumber = 6 Then
Sheets("Saved Sets").Select
Range("A13:EZ13").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Sort Key1:=Range("I49").Value, Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Selection.Sort Key1:=Range("I50").Value, Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Selection.Sort Key1:=Range("I51").Value, Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Selection.Sort Key1:=Range("I52").Value, Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Selection.Sort Key1:=Range("I53").Value, Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Selection.Sort Key1:=Range("I54").Value, Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
ElseIf SortNumber = 7 Then
Sheets("Saved Sets").Select
Range("A13:EZ13").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Sort Key1:=Range("I49").Value, Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Selection.Sort Key1:=Range("I50").Value, Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Selection.Sort Key1:=Range("I51").Value, Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Selection.Sort Key1:=Range("I52").Value, Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Selection.Sort Key1:=Range("I53").Value, Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Selection.Sort Key1:=Range("I54").Value, Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Selection.Sort Key1:=Range("I55").Value, Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
ElseIf SortNumber = 8 Then
Sheets("Saved Sets").Select
Range("A13:EZ13").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Sort Key1:=Range("I49").Value, Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Selection.Sort Key1:=Range("I50").Value, Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Selection.Sort Key1:=Range("I51").Value, Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Selection.Sort Key1:=Range("I52").Value, Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Selection.Sort Key1:=Range("I53").Value, Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Selection.Sort Key1:=Range("I54").Value, Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Selection.Sort Key1:=Range("I55").Value, Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Selection.Sort Key1:=Range("I56").Value, Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End If
'Thirdly, apply the filters in accordance with the requests of the current analysis.
'Adjust the size of the Filter 'CriteriaRange' to match the number of filters
'being applied in the current analysis.
Dim FilterNumber As Integer 'ie:- the number of filter criteria to be applied.
FilterNumber = Sheets("Report").Range("A42").Value
'Now apply filters
If FilterNumber = 1 Then
Sheets("Saved Sets").Select
Range("A13:EZ13").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
Range("D3:D4"), Unique:=False
ElseIf FilterNumber = 2 Then
Sheets("Saved Sets").Select
Range("A13:EZ13").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
Range("E3:E4"), Unique:=False
ElseIf FilterNumber = 3 Then
Sheets("Saved Sets").Select
Range("A13:EZ13").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
Range("F3:F4"), Unique:=False
ElseIf FilterNumber = 4 Then
Sheets("Saved Sets").Select
Range("A13:EZ13").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
Range("G3:G4"), Unique:=False
ElseIf FilterNumber = 5 Then
Sheets("Saved Sets").Select
Range("A13:EZ13").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
Range("H3:H4"), Unique:=False
ElseIf FilterNumber = 6 Then
Sheets("Saved Sets").Select
Range("A13:EZ13").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
Range("I3:I4"), Unique:=False
Else
FilterNumber = 7
Sheets("Saved Sets").Select
Range("A13:EZ13").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
Range("J3:J4"), Unique:=False
End If
End If
'Now select all saved sets in readiness for filtering.
End Sub