Sub CreateSheet()
Application.ScreenUpdating = False
Dim LastRow As Long
LastRow = Sheets("Master List").Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Dim company As Range
Dim ws As Worksheet
Dim rngUniques As Range
Sheets("Master List").Range("D1:D" & LastRow).AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=Range("D1:D" & LastRow), Unique:=True
Set rngUniques = Sheets("Master List").Range("D2:D" & LastRow).SpecialCells(xlCellTypeVisible)
If Sheets("Master List").AutoFilterMode = True Then Sheets("Master List").AutoFilterMode = False
For Each company In rngUniques
Set ws = Nothing
On Error Resume Next
Set ws = Worksheets(company.Value)
On Error GoTo 0
If ws Is Nothing Then
Worksheets.Add(After:=Sheets(Sheets.Count)).Name = company.Value
Sheets("Master List").Range("B1:G1").Copy Cells(1, 1)
End If
Next company
For Each company In rngUniques
Sheets("Master List").Range("D1:D" & LastRow).AutoFilter Field:=1, Criteria1:=company
Sheets("Master List").Range("B2:G" & LastRow).SpecialCells(xlCellTypeVisible).Copy Sheets(company.Value).Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
Range("D1").Select
Sheets(company.Value).Sort.SortFields.Clear
Sheets(company.Value).Sort.SortFields.Add Key:=Range("D2:D" & Sheets(company.Value).Range("D" & Sheets(company.Value).Rows.Count).End(xlUp).Row), _
SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With Sheets(company.Value).Sort
.SetRange Sheets(company.Value).Range("A1:F" & Sheets(company.Value).Range("F" & Rows.Count).End(xlUp).Row)
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
If Sheets("Master List").AutoFilterMode = True Then Sheets("Master List").AutoFilterMode = False
Next company
Application.ScreenUpdating = True
End Sub