I am running the following code to filter info from one sheet to several others, depending on results.
the first section of the code runs well, ie copying to "Back O2.5"
when it moves to the next section, i get 2 issues:
1. a debug on the .Apply - to get around this i need to manually back space the .apply to the previous line then press return to return it to its original place!!
2. When copying the to the worksheet "Home Wins" it keeps copying the orginal top row headers of the original worksheet
Any suggestions on fixes welcome
the first section of the code runs well, ie copying to "Back O2.5"
when it moves to the next section, i get 2 issues:
1. a debug on the .Apply - to get around this i need to manually back space the .apply to the previous line then press return to return it to its original place!!
2. When copying the to the worksheet "Home Wins" it keeps copying the orginal top row headers of the original worksheet
Any suggestions on fixes welcome
VBA Code:
Sub Filterselections()
Dim wsA As Worksheet: Set wsA = Sheets("Match Summaries") ' base data held here
Dim wsB As Worksheet: Set wsB = Sheets("Back O2.5")
Dim wsC As Worksheet: Set wsC = Sheets("Home Wins")
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
With wsA.[a4:ce215].CurrentRegion
.AutoFilter 83, "=Back O2.5" 'filter rows with values O2.5 in CE
.Offset(1).EntireRow.Copy wsB.Range("A" & Rows.Count).End(3)(2) 'copy info to worksheet called Back O2.5
.AutoFilter
Rows("4:4").Select
Selection.AutoFilter
Range("A5:CE3000").Select
ActiveWorkbook.Worksheets("Back O2.5").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Back O2.5").Sort.SortFields.Add2 Key:=Range("C5:C79"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Back O2.5").Sort.SortFields.Add2 Key:=Range("D5:D79"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Back O2.5").Sort
.SetRange Range("A5:CE3000")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
.AutoFilter 9, ">=" & 0.9 'filter rows with values below -0.9 in colum 9 Supremacy DIff
.AutoFilter 79, ">=" & 0.88
.Offset(1).EntireRow.Copy wsC.Range("A" & Rows.Count).End(3)(2) 'copy info to worksheet called Home Wins
.AutoFilter
Rows("4:4").Select
Selection.AutoFilter
Range("A5:CE3000").Select
ActiveWorkbook.Worksheets("Home Wins").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Home Wins").Sort.SortFields.Add2 Key:=Range("C5:C790"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Home Wins").Sort.SortFields.Add2 Key:=Range("D5:D790"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Home Wins").Sort
.SetRange Range("A5:CE3000")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Application.CutCopyMode = False
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End With
End Sub