Sub NewList()
Dim i As Long
Dim rCrit As Range
Const DelRng As String = "E:W,Y:Z,AC:BL" '<- Cols in SheetSL not required
Const FilterVal As Long = 10 '<- Value you want to filter on
Application.ScreenUpdating = False
'Make a copy of 'SL' sheet so we can do what we like with the copy
Sheets("SheetSL").Copy Before:=Sheets(1)
'Use this COPY sheet
With ActiveSheet
'Replace Formulas with their values
With .UsedRange
.Value = .Value
End With
'Delete the unwanted columns
.Range(DelRng).Delete
'Data of interest should now be in A9:Hxx so use that
With .Range("A9", .Range("A" & Rows.Count).End(xlUp)).Resize(, 8)
'Sort on col 'Po'
.Sort Key1:=.Cells(1, 7), Order1:=xlAscending, Header:=xlYes, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
'Move Po, Pl and Di to the left
For i = 7 To 5 Step -1
.Columns(i).Cut
.Cells(1, 1).Insert Shift:=xlToRight
Next i
End With
'Data of interest should be in A9:Hxx but cells have moved
'due to col moves so reset this reference
With .Range("A9", .Range("A" & Rows.Count).End(xlUp)).Resize(, 8)
'Set Adv Filter criteria cells to just right of the data area
Set rCrit = .Offset(, .Columns.Count).Resize(2, 1)
'Fill the criteria cells with heading and filter value
rCrit.Value = Application.Transpose(Array("Index", FilterVal))
'Do the Adv Filter and put results to the right of existing data
.AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=rCrit, _
CopyToRange:=rCrit.Offset(, 2).Resize(1)
End With
'Copy filter results (excluding headings and Index colum) to 'FF' sheet
rCrit.Offset(, 2).CurrentRegion.Offset(1).Resize(, 7).Copy _
Destination:=Sheets("SheetFF").Range("G4")
'Delete the tempory (copy) worksheet
Application.DisplayAlerts = False
.Delete
Application.DisplayAlerts = True
End With
'Activate 'FF' to view results
Sheets("SheetFF").Activate
Application.ScreenUpdating = True
End Sub