Try this:
Sub Main_Sort()
Dim ws1 As Worksheet: Set ws1 = Sheets("Activity")
Dim ws2 As Worksheet: Set ws2 = Sheets("Top Users")
Dim ws3 As Worksheet: Set ws3 = Sheets("Top Question")
Dim ws4 As Worksheet: Set ws4 = Sheets("Top Answer")
Dim ws5 As Worksheet: Set ws5 = Sheets("Top Chat")
Dim ws6 As Worksheet: Set ws6 = Sheets("Top DM")
Dim ws7 As Worksheet: Set ws7 = Sheets("Top MG")
Dim ws8 As Worksheet: Set ws8 = Sheets("Top MR")
Dim lastrow As Long, rowCount As Long
Application.ScreenUpdating = False
lastrow = ws1.Range("A" & Rows.Count).End(xlUp).Row
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'same code just modified for each sort parameter
rowCount = ws2.Range("D3").Value
ws1.Sort.SortFields.Clear
ws1.Sort.SortFields.Add Key:=Range("B2:B" & lastrow), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ws1.Sort
.SetRange Range("A1:H" & lastrow)
.Header = xlYes
.Apply
End With
ws1.Range("A2:A" & rowCount).EntireRow.Copy Destination:=ws3.Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
rowCount = ws2.Range("D4").Value
ws1.Sort.SortFields.Clear
ws1.Sort.SortFields.Add Key:=Range("C2:C" & lastrow), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ws1.Sort
.SetRange Range("A1:H" & lastrow)
.Header = xlYes
.Apply
End With
ws1.Range("A2:A" & rowCount).EntireRow.Copy Destination:=ws4.Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
rowCount = ws2.Range("D5").Value
ws1.Sort.SortFields.Clear
ws1.Sort.SortFields.Add Key:=Range("D2:D" & lastrow), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ws1.Sort
.SetRange Range("A1:H" & lastrow)
.Header = xlYes
.Apply
End With
ws1.Range("A2:A" & rowCount).EntireRow.Copy Destination:=ws5.Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
rowCount = ws2.Range("D6").Value
ws1.Sort.SortFields.Clear
ws1.Sort.SortFields.Add Key:=Range("E2:E" & lastrow), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ws1.Sort
.SetRange Range("A1:H" & lastrow)
.Header = xlYes
.Apply
End With
ws1.Range("A2:A" & rowCount).EntireRow.Copy Destination:=ws6.Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
rowCount = ws2.Range("D7").Value
ws1.Sort.SortFields.Clear
ws1.Sort.SortFields.Add Key:=Range("F2:F" & lastrow), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ws1.Sort
.SetRange Range("A1:H" & lastrow)
.Header = xlYes
.Apply
End With
ws1.Range("A2:A" & rowCount).EntireRow.Copy Destination:=ws7.Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
rowCount = ws2.Range("D8").Value
ws1.Sort.SortFields.Clear
ws1.Sort.SortFields.Add Key:=Range("G2:G" & lastrow), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ws1.Sort
.SetRange Range("A1:H" & lastrow)
.Header = xlYes
.Apply
End With
ws1.Range("A2:A" & rowCount).EntireRow.Copy Destination:=ws8.Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Application.ScreenUpdating = True
End Sub
Bookmarks