我正在尝试重复此过程x次,但我不断收到消息“编译错误:无需循环”
这是我的代码
Do Until x > 10
x = x + 1
For Each Row In propertytable
Range("A2,B2,C2,D2,E2").Select
Range("E2").Activate
Selection.Copy
Sheets("Copy to' sheet").Select
Range("A1").Select
ActiveSheet.Paste
Rows("1:1").Select
Application.CutCopyMode = False
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Sheets("Property table").Select
Rows("2:2").Select
Selection.Delete Shift:=xlUp
Sheets("Copy to' sheet").Select
Loop
提前感谢您提供的任何帮助。
答案 0 :(得分:2)
缩进代码会使Next Row
的遗漏更加明显。
Do Until x > 10
x = x + 1
For Each Row In propertytable
Range("A2,B2,C2,D2,E2").Select
Range("E2").Activate
Selection.Copy
Sheets("Copy to' sheet").Select
Range("A1").Select
ActiveSheet.Paste
Rows("1:1").Select
Application.CutCopyMode = False
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Sheets("Property table").Select
Rows("2:2").Select
Selection.Delete Shift:=xlUp
Sheets("Copy to' sheet").Select
'with indent it's obvious there's something missing
Next Row
Loop
我认为在添加Next Row
命令后,您可能会遇到其他一些编译错误。