See this example. I am not using the Inputbox
for taking input but rather using a hard coded value for demonstration purpose.
Lets say your Excel data looks like this.
Simply paste this code in a module and run it.
Code
'
' Excel Constants for Months for Autofilter
'
' xlFilterAllDatesInPeriodJanuary = 21
' xlFilterAllDatesInPeriodFebruray = 22
' xlFilterAllDatesInPeriodMarch = 23
' xlFilterAllDatesInPeriodApril = 24
' xlFilterAllDatesInPeriodMay = 25
' xlFilterAllDatesInPeriodJune = 26
' xlFilterAllDatesInPeriodJuly = 27
' xlFilterAllDatesInPeriodAugust = 28
' xlFilterAllDatesInPeriodSeptember = 29
' xlFilterAllDatesInPeriodOctober = 30
' xlFilterAllDatesInPeriodNovember = 31
' xlFilterAllDatesInPeriodDecember = 32
Sub Sample()
Dim ws As Worksheet
Dim lRow As Long, lMnth As Long, constmonth As Long
'~~> Feb
lMnth = 2
constmonth = lMnth + 20 '~~> (See the commented section for constants)
'~~> Change this to the relevant sheet
Set ws = ThisWorkbook.Sheets("Sheet1")
With ws
lRow = .Range("A" & .Rows.Count).End(xlUp).Row
'~~> Remove any filters
.AutoFilterMode = False
With .Range("A1:A" & lRow)
.AutoFilter Field:=1, Criteria1:= _
constmonth, Operator:=xlFilterDynamic
End With
End With
End Sub
Output