See attached file.
This is the macro I used:
Sub FilterByDateRange()
'
Dim DateIni As Date
Dim DateEnd As Date
Dim DateIniAF As Long
Dim DateEndAF As Long
Dim sh As Worksheet, freeRow As Long, maxRow As Long
Dim sh1 As Worksheet
Dim found As Range
'
DateIni = InputBox("Date From in dd-mmm-yy format")
DateIni = DateSerial(Year(DateIni), Month(DateIni), Day(DateIni))
DateIniAF = DateIni
DateEnd = InputBox("Date To in dd-mmm-yy format")
DateEnd = DateSerial(Year(DateEnd), Month(DateEnd), Day(DateEnd))
DateEndAF = DateEnd
Set sh1 = ThisWorkbook.Sheets("1 Mth")
For Each sh In ThisWorkbook.Sheets
If LCase(sh.Name) Like "z*" Then
sh.AutoFilterMode = False
Set found = sh.Range("a:a").Find("POSITION NUMBER", LookIn:=xlValues)
If Not found Is Nothing Then
sh.Range(found.Row & ":" & Rows.Count).AutoFilter Field:=40, Criteria1:=">=" & DateIniAF, Operator:=xlAnd, Criteria2:="<=" & DateEndAF
sh.Range(found.Row & ":" & Rows.Count).AutoFilter Field:=43, Criteria1:="VACANT"
freeRow = sh1.Cells(Rows.Count, "a").End(xlUp).Row + 1
maxRow = sh.UsedRange.Rows.Count + sh.UsedRange.Row - 1
sh.Range(found.Row + 1 & ":" & maxRow).SpecialCells(xlCellTypeVisible).Copy sh1.Cells(freeRow, "a")
End If
End If
Next sh
End Sub
Regards,
Antonio
Bookmarks