笨笨魚
2005-09-02 06:55:37 UTC
小弟寫了以下程式碼
為何會發生執行階段錯誤”9”陣列索引超出範圍?
Sub 匯入項次()
Set a = Sheets("日報表150項(A3)")
Set b = Sheets("日報表27項(A4)")
Set c = Sheets("日報表48項(A4)")
Set d = Sheets("日報表75項(A4)")
For i = 1 To 105
a.Cells(i + 12, 2).Value = Cells(i + 2, 2).Value
For j = 1 To 45
a.Cells(j + 12, 18).Value = Cells(j + 107, 3).Value
Next j
For k = 1 To 27
b.Cells(k + 7, 1).Value = Cells(i + 2, 2).Value
Next k
For l = 1 To 48
c.Cells(l + 8, 1).Value = Cells(i + 2, 3).Value
Next l
For m = 1 To 70
d.Cells(l + 7, 1).Value = Cells(i + 2, 3).Value
Next m
For n = 1 To 19
d.Cells(l + 7, 8).Value = Cells(i + 2, 3).Value
Next n
Next i
End Sub
希望各位先進能不吝指教,幫小弟解惑
為何會發生執行階段錯誤”9”陣列索引超出範圍?
Sub 匯入項次()
Set a = Sheets("日報表150項(A3)")
Set b = Sheets("日報表27項(A4)")
Set c = Sheets("日報表48項(A4)")
Set d = Sheets("日報表75項(A4)")
For i = 1 To 105
a.Cells(i + 12, 2).Value = Cells(i + 2, 2).Value
For j = 1 To 45
a.Cells(j + 12, 18).Value = Cells(j + 107, 3).Value
Next j
For k = 1 To 27
b.Cells(k + 7, 1).Value = Cells(i + 2, 2).Value
Next k
For l = 1 To 48
c.Cells(l + 8, 1).Value = Cells(i + 2, 3).Value
Next l
For m = 1 To 70
d.Cells(l + 7, 1).Value = Cells(i + 2, 3).Value
Next m
For n = 1 To 19
d.Cells(l + 7, 8).Value = Cells(i + 2, 3).Value
Next n
Next i
End Sub
希望各位先進能不吝指教,幫小弟解惑
--
請多多指教
請多多指教