我试图使用此代码剪切和粘贴一些数据:
For c = p To 12
If Sheets("Hoja2").Cells(4, 3 + c + yy).Value <> "Total general" Then
c2 = p - 1
dif = Sheets("Hoja2").Cells(4, 3 + c + yy).Value - Sheets("Hoja2").Cells(4, 3 + c2 + yy).Value
If Sheets("Hoja2").Cells(4, 3 + c + yy).Value - Sheets("Hoja2").Cells(4, 3 + c2 + yy).Value <> 1 Then
Sheets("Tabla Final REV").Range(Cells(5, (4 * (e * 3 + t) + 4 * (1 - t) + p - 1)), Cells(variablefinalfila, 15)).Cut Sheets("Tabla Final REV").Range(Cells(5, (4 * (e * 3 + t) + 4 * (1 - t) + p + dif - 1 - 1)), Cells(5, (4 * (e * 3 + t) + 4 * (1 - t) + p + dif - 1 - 1)))
End If
Else
Exit For
End If
Next c
但它并没有粘贴任何东西。
换句话说,我的代码只是:
For x = 1 to 12
if condition
if othercondition
Sheets("Mysheet").Range(cells(number,number2), cells(number3,number4)). Cut Sheets("Mysheet").Range(cells(anumber,anumber2),cells(anumber,anumber2))
我可以做些什么来改善它?
答案 0 :(得分:1)
限定那些Cells
可以修复它:
With Sheets("Tabla Final REV")
.Range(.Cells(5, (4 * (e * 3 + t) + 4 * (1 - t) + p - 1)), .Cells(variablefinalfila, 15)).Cut .Range(.Cells(5, (4 * (e * 3 + t) + 4 * (1 - t) + p + dif - 1 - 1)), .Cells(5, (4 * (e * 3 + t) + 4 * (1 - t) + p + dif - 1 - 1)))
End With
注意.Cells