Option Base 1
Sub YTDmacro()
Dim MyArray As Variant
Dim Reply
Reply = InputBox("Enter the month using the first 3 letters.")
'Did user choose Cancel?
If Reply = "" Then Exit Sub
Select Case LCase(Reply)
Case Is = "jan"
MyArray = Array(3,4)
Case Is = "feb"
MyArray = Array(3,4,5)
Case Is = "mar"
MyArray = Array(3,4,5,6)
Case Is = "apr"
MyArray = Array(3,4,5,6,7)
Case Is = "may"
MyArray = Array(3,4,5,6,7,8)
Case is = "jun"
MyArray = Array(3,4,5,6,7,8,9)
Case Is = "jul"
MyArray = Array(3,4,5,6,7,8,9,10)
Case Is = "aug"
MyArray = Array(3,4,5,6,7,8,9,10,11)
Case Is = "sep"
MyArray = Array(3,4),5,6,7,8,9,10,11,12)
Case Is = "oct"
MyArray = Array(3,4,5,6,7,8,9,10,11,12,13)
Case Is = "nov"
MyArray = Array(3,4,5,6,7,8,9,10,11,12,13,14)
Case Is = "dec"
MyArray = Array(3,4,5,6,7,8,9,10,11,12,13,14,15)
Case Else
MsgBox "Month " & Reply & " is invalid."
Exit Sub
End Select
Range("A3").Subtotal GroupBy:=1, Function:=xlSum, _
TotalList:=MyArray, Replace:=True, _
PageBreaks:=False, SummaryBelowData:=True
End Sub
Sincerely,
Bookmarks