New to VBA and have built the below, however I am running the code 17 times as there are 17 different teams and thus 17 different filtering variations. I feel like this is too complicated and has made the file unstable. Any help to simplify this would really be appreciated
Sheets("All Data").Select
Sheets("All Data").Rows(8).Select
Selection.AutoFilter
Sheets("All Data").Cells(1).AutoFilter Field:=5, Criteria1:=Array("name1", "name2", "name3",
"name4"), Operator:=xlFilterValues
Sheets("All Data").UsedRange.Offset(1, 0).SpecialCells(xlCellTypeVisible).Select
Range("A8").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Sheets("team1").Select
Range("A42").Select
ActiveSheet.Paste
Sheets("All Data").Activate
Sheets("All Data").Rows(8).Select
Selection.AutoFilter
Sheets("All Data").Cells(1, 1).Select
Application.CutCopyMode = False
Sheets("team1").Select
Range("N42").Select
Selection.AutoFilter
ActiveWorkbook.Worksheets("team1").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("team1").AutoFilter.Sort.SortFields.Add2 Key:=Range _
("N42:N10000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("team1").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom`
.SortMethod = xlPinYin
.Apply
End With'''