我正在尝试制作一个移动单元格范围的程序,但是我的一个 Do 循环不起作用。尤其是对列元素的爬取。当程序运行时,只填充 A7:A9 而不是 A7:J9。爬行确实适用于第 1 行到 L1 的移动,并且如果红线中没有值(如果 A10 为空白,则 B7:B9 将填充)。我的错误是什么?
Sub Columntest()
Dim i As Integer, j As Integer, k As Integer
i = 1
j = 2
k = 7
Do Until i = 11
Range("L1").Formula = Cells(1, i)
If Cells(10, i).Value = "Low" Then
Do Until j = 6
Cells(j + 15, 1).Formula = Cells(j, i)
j = j + 1
Loop
Do Until k = 10
Cells(k + 5, 1).Copy
Cells(k, i).PasteSpecial xlPasteValues
k = k + 1
Loop
End If
If Cells(10, i).Value = "High" Then
Do Until j = 6
Cells(j + 15, 1).Formula = Cells(j, i)
j = j + 1
Loop
Do Until k = 10
Cells(k + 5, 2).Copy
Cells(k, i).PasteSpecial xlPasteValues
k = k + 1
Loop
End If
i = i + 1
Loop
结束子