I'm new to Excel VBA and started to build a time tracking workbook for learning. A part of that is a For-Loop which shall add one named worksheet for every month in a year:
Sub newyear()
Dim month(12) As String
Dim i As Integer
month(1) = "Januar"
month(2) = "Februar"
...
month(12) = "Dezember"
For i = 1 To 12
On Error Resume Next
Sheets.Add(Tabelle1).Name = month(i)
MsgBox Err.Number <- this throws Error 9: "Subscript Out Of Range" after
every worksheet added during the loop
Next i
End Sub
During Runtime while the loop is adding worksheet after worksheet the MsgBox pops up after every single added sheet with Error 9: "Subscript Out Of Range".
I don't know why this is happening, started reading up quite a bit on the web and still have no solution.. maybe I'm missing something basic, because I'm a beginner.
Please help me.
Thanks in advance!