在取消循环中有多个需要更改的变量的函数时遇到问题。我的数据存放在几行但令人讨厌的列中。我正在获取数据并将其堆叠在一起,以便对其进行更多操作。我需要一种方法来同时更改两个变量y
,否则它会陷入无限循环并崩溃。n
next
我希望y
's 继续正常步骤,但需要n
's 与它们一起更改,否则数据只是覆盖并且它会重复自身。
Sub pasteanswers()
Dim LastCol As Integer
Dim y As Integer
Dim x As Integer
Dim n As Integer
Dim v As Integer
With ActiveSheet
LastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column - 7
r2s = (LastCol / 2)
End With
For x = 6 To 28
For n = 1 To r2s
For y = 6 To 1721
Cells(y, 8).Value = Cells(x, ((2 * n + 8))).Value
Cells(y, 9).Value = Cells(x, ((2 * n) + 9)).Value
Next y
Next n
Next x
End Sub