I want to change the column select range from A to B with top 5 rows freeze in every sheet and then split
VBA Code:
Sub sheets_seperator()
Dim flpath As String
Dim lr As Integer
Application.DisplayAlerts = False
Application.ScreenUpdating = False
cnt = 1
flpath = Application.InputBox("Enter the file location") & "\"
On Error Resume Next
On Error Resume Next
Sheets("List").Delete
Sheets.Add(After:=Sheets(Sheets.Count)).Name = "List"
Sheets("Rep_1").Select
Columns("a:a").Copy
Sheets("List").Select
Range("A1").PasteSpecial xlPasteValuesAndNumberFormats
Range("A:A").RemoveDuplicates 1, xlYes
Range("A1").Select
Range("A1:A2").EntireRow.Delete
Columns.AutoFit
ActiveSheet.UsedRange.AutoFilter 1, "*Total*"
Sheets("List").AutoFilter.Range.Offset(1).Delete xlShiftUp
ActiveSheet.ShowAllData
Set mstrwb = ThisWorkbook
lr = Sheets("List").Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lr
Teamname = Cells(i, 1).Value
Workbooks.Add
ActiveWorkbook.SaveAs flpath & Teamname & "- Report" & ".xlsx", FileFormat:=51
Set extr = ActiveWorkbook
For Each ws In mstrwb.Worksheets
ws.Copy After:=extr.Sheets(Sheets.Count)
Next ws
Sheets("List").Delete
Sheets(1).Delete
For Each ws In extr.Sheets
ws.Select
Range("a4").Select
Rows("4:4").Select
Selection.AutoFilter
Selection.AutoFilter 1, "<>" & "*" & Teamname & "*"
Range("a4").Select
ActiveSheet.AutoFilter.Range.Offset(1).Delete xlShiftUp
ActiveSheet.ShowAllData
Range("a5").Select
Next ws
Sheets(2).Select
ActiveWorkbook.Close True
cnt = cnt + 1
Next i
MsgBox cnt - 1 & " Files created Successfully"
End Sub