我正試圖運行循環中指數在同一時間更改的循環。VBA中的雙循環
For i = 0 To 20 Step 5
For j = 0 To 5 Step 1
Range(ActiveCell, ActiveCell.Offset(5 + i, 0)).Copy Destination:=Cells(8, 12 + j)
Next i
Next j
我試圖讓循環做到這一點
Range(ActiveCell, ActiveCell.Offset(5 + 0, 0)).Copy Destination:=Cells(8, 12 + 0)
Range(ActiveCell, ActiveCell.Offset(5 + 5, 0)).Copy Destination:=Cells(8, 12 + 1)
Range(ActiveCell, ActiveCell.Offset(5 + 10, 0)).Copy Destination:=Cells(8, 12 + 2)
Range(ActiveCell, ActiveCell.Offset(5 + 15, 0)).Copy Destination:=Cells(8, 12 + 3)
Range(ActiveCell, ActiveCell.Offset(5 + 20, 0)).Copy Destination:=Cells(8, 12 + 4)
迴路我有unfortuantly做到這一點:
Range(ActiveCell, ActiveCell.Offset(5 + 0, 0)).Copy Destination:=Cells(8, 12 + 0)
Range(ActiveCell, ActiveCell.Offset(5 + 5, 0)).Copy Destination:=Cells(8, 12 + 0)
Range(ActiveCell, ActiveCell.Offset(5 + 10, 0)).Copy Destination:=Cells(8, 12 + 0)
...
Range(ActiveCell, ActiveCell.Offset(5 + 0, 0)).Copy Destination:=Cells(8, 12 + 1)
Range(ActiveCell, ActiveCell.Offset(5 + 5, 0)).Copy Destination:=Cells(8, 12 + 1)
我想我可以有一個循環這樣的:但這並不完全。
For i = 0 To 20 Step 5
Range(ActiveCell, ActiveCell.Offset(5 + i, 0)).Copy Destination:=Cells(8, 12 + j-4)
Next j
任何人都可以提出對具有環,其中indicies都在同一時間同時改變任何想法?謝謝!!
我認爲這個問題是「接下來我 下一步J」我想你搞砸了,應該是「下一個J下我」? – Larry