我試圖讓我的陣列,以調整在我的工作簿中的張數的長度,但不斷收到VBA不能得到陣列來調整
下標越界
對於我的情況下工作表名稱是「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
我正在使用ReDim(請參見第5行),但仍然出現錯誤。 – nothing