My code works perfectly except it creates an extra sheet (whatever is next in the sequence...i.e "Sheet2".."Sheet3"...each time I run it. Could anyone help figure out why this is happening?...there should only be two Sheets Created as I have indicated in the code below:
Sub CopySheet()
Dim NewSheet As String
Dim PrevSheet As String
Dim CashWS As Worksheet
Dim MonthVal As String
NewSheet = InputBox("Which month is this Commissions statement for?")
PrevSheet = InputBox("What was the previous month?")
Worksheets(PrevSheet).Copy After:=Worksheets("Summary")
ActiveSheet.Name = NewSheet
Range("D2").Select
ActiveCell.FormulaR1C1 = "=EOMONTH(DATE(2017,MONTH(DATEVALUE(MID(CELL(""filename"", RC[-5]), FIND(""]"", CELL(""filename"", RC[-5])) + 1, 255)&""1"")+1),1),0)"
Selection.NumberFormat = "m/d/yyyy"
Range("D3").Select
ActiveCell.FormulaR1C1 = "=MONTH(R[-1]C)"
Range("D3").Select
Selection.NumberFormat = "General"
MonthVal = ActiveCell.Value
Set CashWS = Sheets.Add
Sheets.Add.Name = "2017_0" & MonthVal & " Cash"
End Sub