I have VBA code, it works when the filter date requirement is complete but if it's not complete, it will copy the header instead. Please check my code below:
Sub Macro7()
'
' Macro7 Macro
'
Dim LastRow As Long
On Error Resume Next
Range("c6").Select
Sheets("Ref2").Select
ActiveSheet.Range("$A$1:$O$168").AutoFilter Field:=3, Criteria1:=Sheets("NOV 2022").Range("E1").Value
ActiveSheet.Range("$A$1:$O$168").AutoFilter Field:=4, Criteria1:=Sheets("NOV 2022").Range("A6").Value
LastRow = Range("E" & Rows.Count).End(xlUp).Row
Range("E2:O" & LastRow).SpecialCells(xlCellTypeVisible).Select
Selection.copy
Sheets("NOV 2022").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveWindow.SmallScroll Down:=21
Sheets("Ref2").Select
ActiveSheet.Range("$A$1:$O$168").AutoFilter Field:=4, Criteria1:=Sheets("NOV 2022").Range("A37").Value
LastRow = Range("E" & Rows.Count).End(xlUp).Row
Range("E2:O" & LastRow).SpecialCells(xlCellTypeVisible).Select
Selection.copy
Sheets("NOV 2022").Select
Range("C37").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveWindow.SmallScroll Down:=21
Range("C58").Select
Sheets("Ref2").Select
ActiveSheet.Range("$A$1:$O$168").AutoFilter Field:=4, Criteria1:=Sheets("NOV 2022").Range("A58").Value
LastRow = Range("E" & Rows.Count).End(xlUp).Row
Range("E2:O" & LastRow).SpecialCells(xlCellTypeVisible).Select
Selection.copy
Sheets("NOV 2022").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveWindow.SmallScroll Down:=27
Range("C93").Select
Sheets("Ref2").Select
ActiveSheet.Range("$A$1:$O$168").AutoFilter Field:=4, Criteria1:=Sheets("NOV 2022").Range("A93").Value
LastRow = Range("E" & Rows.Count).End(xlUp).Row
Range("E2:O" & LastRow).SpecialCells(xlCellTypeVisible).Select
Selection.copy
Sheets("NOV 2022").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub
Sub Macro7()
'
' Macro7 Macro
'
Dim LastRow As Long
On Error Resume Next
Range("c6").Select
Sheets("Ref2").Select
ActiveSheet.Range("$A$1:$O$168").AutoFilter Field:=3, Criteria1:=Sheets("NOV 2022").Range("E1").Value
ActiveSheet.Range("$A$1:$O$168").AutoFilter Field:=4, Criteria1:=Sheets("NOV 2022").Range("A6").Value
LastRow = Range("E" & Rows.Count).End(xlUp).Row
Range("E2:O" & LastRow).SpecialCells(xlCellTypeVisible).Select
Selection.copy
Sheets("NOV 2022").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveWindow.SmallScroll Down:=21
Sheets("Ref2").Select
ActiveSheet.Range("$A$1:$O$168").AutoFilter Field:=4, Criteria1:=Sheets("NOV 2022").Range("A37").Value
LastRow = Range("E" & Rows.Count).End(xlUp).Row
Range("E2:O" & LastRow).SpecialCells(xlCellTypeVisible).Select
Selection.copy
Sheets("NOV 2022").Select
Range("C37").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveWindow.SmallScroll Down:=21
Range("C58").Select
Sheets("Ref2").Select
ActiveSheet.Range("$A$1:$O$168").AutoFilter Field:=4, Criteria1:=Sheets("NOV 2022").Range("A58").Value
LastRow = Range("E" & Rows.Count).End(xlUp).Row
Range("E2:O" & LastRow).SpecialCells(xlCellTypeVisible).Select
Selection.copy
Sheets("NOV 2022").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveWindow.SmallScroll Down:=27
Range("C93").Select
Sheets("Ref2").Select
ActiveSheet.Range("$A$1:$O$168").AutoFilter Field:=4, Criteria1:=Sheets("NOV 2022").Range("A93").Value
LastRow = Range("E" & Rows.Count).End(xlUp).Row
Range("E2:O" & LastRow).SpecialCells(xlCellTypeVisible).Select
Selection.copy
Sheets("NOV 2022").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub