这个简单的宏在178次迭代后停止,并显示错误28消息。如何绕过此问题以便宏继续运行?我在论坛上尝试了很多建议而没有成功。我使用的是Excel 2007。 D Hatch Bilthoven NL
Sub Macro1()
' Macro1 Macro
' Keyboard Shortcut: Ctrl+a
ActiveCell.Range("A1:B1").Select
Selection.Copy
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
ActiveCell.Offset(-1, 0).Range("A1:B1").Select
Application.CutCopyMode = False
Selection.Copy
ActiveCell.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveCell.Offset(1, 0).Range("A1").Select
Application.Run "Macro1"
End Sub
答案 0 :(得分:1)
答案 1 :(得分:0)
您没有提供退出方法的方法,而无需再次调用自己。
您需要执行以下操作之一: -
Application.Run "Macro1"
代码添加条件/测试,以便您有机会退出Application.Run "Macro1"
。说实话,如果不被If/Then/Else
事实上,这种方法似乎没有意义。如果要在工作表中复制两个单元格,可以采用更快捷的方式执行此操作: -
ActiveCell.Range("A1:B1").Select
Selection.Copy
'Select the range you want to copy it down to - but there must be *some* limit!
ActiveCell.Offset(1, 0).Range("A1:B1000").Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.Offset(-1, 0).Select
答案 2 :(得分:0)
您需要执行以下步骤:-
Sub macromethod()
you need to all write method name simple and then exiting method call in
macromethod
End Sub
如果要调用一个模块到另一个模块的方法,则可以使用 Call macromethod (在调用方法中使用相同的方法)来简单地只编写 macromethod