I am trying to get my array to resize to the length of the number of sheets in my workbook but keep getting
Subscript out of range
For context my sheet names are "Year XXXX"
Dim sheetsForCalendar() As Integer
For Each Worksheet In ThisWorkbook.Sheets
Dim i As Integer: i = 0
Dim calendarYear() As String: calendarYear() = Split(CStr(Worksheet.Name))
ReDim Preserve sheetsForCalendar(i)
If calendarYear(0) = "Year" Then
Dim calendarYearAsInt As Integer: calendarYearAsInt = calendarYear(1)
sheetsForCalendar(i) = calendarYearAsInt
End If
i = i + 1
Next
For Each element In sheetsForCalendar
MsgBox (sheetsForCalendar(element))
Next