我有一些宏在Excel中复制我的工作表,并删除某些数据。不幸的是,分配宏的按钮在运行宏时不会复制。
Sub CandD()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim sh As Shape, strtSh As Worksheet
Set strtSh = ActiveSheet
Sheets("BM Condition").Copy After:=Sheets(Sheets.Count)
ActiveSheet.Name = "BM Condition" & Sheets.Count - 1
Range("E14:E33,I14:I33,M14:M33").ClearContents
For Each sh In ActiveSheet.Shapes
sh.Delete
Next sh
strtSh.Select
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
这是我正在使用的宏。我的VBA体验非常有限,并没有找到谷歌非常有帮助。有人可以推荐修复我的按钮而不是复制吗?
编辑:我忘了提到手动复制按钮时仍然存在。我不知道为什么会这样。答案 0 :(得分:-1)
正如FunThomas所提到的,我已经尝试并测试了以下内容而没有任何错误:
Sub CanD()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim sh As Shape, strtSh As Worksheet
Set strtSh = ActiveSheet
Sheets("BM Condition").Copy After:=Sheets(Sheets.Count)
ActiveSheet.Name = "BM Condition" & Sheets.Count - 1
Range("E14:E33,I14:I33,M14:M33").ClearContents
strtSh.Select
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub