2017-06-15 260 views
0

我正在用VBA寫一個宏。如果你在excel中按下按鈕,它將會優先執行代碼。以下是代碼的第一部分。如果我超出程序,那麼我得到運行時錯誤9,下標超出範圍。我怎樣才能解決這個錯誤?錯誤指向ReDim rij(1 To z) As Integer宏運行時錯誤'9':下標超出範圍與宏

ThisWorkbook.Sheets("InvoerIO").Range("O1") = z 

ReDim rij(1 To z) As Integer 

For r = 1 To ThisWorkbook.Sheets("InvoerIO").Range("O1")   
    If r > 7 Then 
     z = ThisWorkbook.Sheets("InvoerIO").Range("O1") 
     rij(r) = rij(r - 1)  
     If Sheets("InvoerIO").Cells(r, 3).value = "part1" Then   
      rij(r) = 90 

+1

不'z'採取什麼樣的價值? – CallumDA

+0

z是一個整數 – Johan

回答

0

變化

ThisWorkbook.Sheets("InvoerIO").Range("O1") = z 

z = ThisWorkbook.Sheets("InvoerIO").Range("O1").Value 
相關問題