Sub FiltTest3ish()
Dim x As Long, y As Long, RESP1 As String, RESP2 As String, Shtx As Worksheet, LstRw As Long
Dim LstRw2 As Long, icol As Long
RESP1 = InputBox("Choose the number which represents the month you want to filter from.")
RESP2 = InputBox("Choose the number which represents the month you want to filter to.")
Application.ScreenUpdating = False
Set Shtx = Blad1
With Shtx.Range("O4:O" & Shtx.Range("C" & Rows.Count).End(xlUp).Row)
.FormulaR1C1 = "=MONTH(RC[-3])"
.Value = .Value
With .Offset(, 1)
.FormulaR1C1 = "=YEAR(RC[-15])"
.Value = .Value
End With
End With
x = RESP1
y = RESP2 - 1
Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = "MyTest"
LstRw = Shtx.Range("C" & Rows.Count).End(xlUp).Row
With Shtx.Range("A3:R" & LstRw)
.AutoFilter Field:=15, Criteria1:= _
">=" & x, Operator:=xlAnd, Criteria2:="<=" & y
.AutoFilter Field:=16, Criteria1:="=2014", _
Operator:=xlOr, Criteria2:="=2015"
On Error Resume Next
.Offset(-2).Resize(.Rows.Count + 3).SpecialCells(xlCellTypeVisible).Copy
With Sheets("MyTest").Range("C" & Rows.Count).End(xlUp).Offset(1, -2)
.PasteSpecial xlPasteColumnWidths
.PasteSpecial
End With
On Error GoTo 0
.AutoFilter
End With
With Sheets("MyTest")
LstRw2 = .Cells(Rows.Count, "C").End(xlUp).Row
For icol = 6 To 9
.Cells(LstRw2 + 3, icol).Formula = "=SUM(" & .Range(.Cells(5, icol), .Cells(LstRw2, icol)).Address & ")"
Next
.Cells(LstRw2 + 3, 13).Formula = "=SUM(" & .Range(.Cells(5, 13), .Cells(LstRw2, 13)).Address & ")"
.Columns("N:O").Delete
End With
Blad1.Columns("O:P").Delete
Application.ScreenUpdating = True
End Sub