Sub EachDayOfMonthTab()
Dim TabName As Worksheet
Dim sMonth As Integer
Dim DaysInMonth As Integer
Dim i As Integer
sMonth = GetMonth
If sMonth = 0 Then Exit Sub
DaysInMonth = Day(DateSerial(Year(Date), sMonth + 1, 1) - 1)
For i = 1 To DaysInMonth
On Error Resume Next
Set TabName = Worksheets(i & "-" & MonthName(sMonth, True))
If Err.Number = 9 Then
If i < 4 Then
Worksheets(i).Name = i & "-" & MonthName(sMonth, True)
Else
'add new worksheet & name with next day date
Worksheets.Add(after:=Worksheets(Worksheets.Count)).Name = _
i & "-" & MonthName(sMonth, True)
End If
On Error GoTo 0
End If
Next i
End Sub
Function GetMonth() As Integer
Dim GetInput As Variant
Dim MonthArr(12) As Variant
Dim msg As String
Dim abbrv As Boolean
Dim i As Integer
msg = "Please Enter Required Month Name" & Chr(10) & _
" E.G. Jan or January" & Chr(10) & Chr(10) & _
" or" & Chr(10) & Chr(10) & _
"You Can Enter Months Numeric Value" & Chr(10) & _
" E.G 1 = January"
Retry:
GetInput = InputBox(msg, "Enter Month")
If StrPtr(GetInput) = 0 Then
GetMonth = 0
Exit Function
ElseIf Len(GetInput) = 0 Then
MsgBox "Month Cannot be Blank", 16, "Entry Required"
GoTo Retry
Else
If IsNumeric(GetInput) Then
If GetInput > 0 And GetInput < 13 Then
GetMonth = CInt(GetInput)
Exit Function
Else
MsgBox "Invaild Input" & Chr(10) & _
"Please Enter A Valid Month Name Or Number", 16, "Invalid Input"
GoTo Retry
End If
Else
If Len(GetInput) = 3 Then abbrv = True
For i = 1 To 12
MonthArr(i - 1) = MonthName(i, abbrv)
Next i
On Error Resume Next
GetMonth = Application.Match(GetInput, MonthArr, False)
If IsError(GetMonth) Then GetMonth = 0
On Error GoTo 0
End If
End If
End Function