Sub extraire()
Dim derlig As Integer
Dim tablo()
'Filter the 2nd and 3rd columns
ActiveSheet.Range("$A$1:$O$9950").AutoFilter Field:=2, Criteria1:="#N/A"
ActiveSheet.Range("$A$1:$O$9950").AutoFilter Field:=3, Criteria1:= _
"=Ind Eng", Operator:=xlOr, Criteria2:="=Landis"
'Create a new sheet called Sheet2
Sheets.Add.Move After:=Sheets(Sheets.Count)
Sheets(Sheets.Count).Name = "Sheet2"
Sheets("Planned Orders").Select
'Macro for create a table in an other sheet, with the Plnd order numbers,
'and extract the TRUNKING and SM numbers in the period : Current date + 1 month - end of third next month
date1Mois = DateSerial(Year(Date), Month(Date) + 1, Day(Date))
date4Mois = DateSerial(Year(Date), Month(Date) + 4, 1) - 1
Sheets(2).[A1].CurrentRegion.ClearContents
derlig = cells(Rows.Count, 9).End(xlUp).Row
For Each c In Range("I2:I" & derlig).SpecialCells(xlCellTypeVisible)
If c >= date1Mois And c <= date4Mois And _
Left(cells(c.Row, 1), 2) <> "SM" And InStr(1, cells(c.Row, 4), "trunking", 1) = 0 Then
ReDim Preserve tablo(1, x)
tablo(0, x) = cells(c.Row, 1)
tablo(1, x) = cells(c.Row, 7)
x = x + 1
End If
Next c
If IsEmpty(x) Then Exit Sub 'To avoid error if tablo is empty
Sheets("Sheet2").[A1].Resize(x, 2) = Application.Transpose(tablo)
Sheets("Sheet2").Select
End Sub