首页 > 解决方案 > 没有附加到该表的应对代码的重复表

问题描述

我对您建议的删除代码的代码有疑问。我想删除重复工作表“Overview 10 years (2)”中 Excel 对象上激活的所有代码,这样我就可以继续运行而不会干扰其他代码。我做这件事的方式有什么遗漏吗?

Sheets(Array("Overview 10 years", "Overview monthly")).Select
Sheets("Overview 10 years").Activate
Sheets(Array("Overview 10 years", "Overview monthly")).Copy Before:=Sheets(1 _
    )
Sheets("Overview 10 years (2)").Activate
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False

' Get the code/object name of the new sheet...
Dim StrObjectName As String
StrObjectName = Sheets("Overview 10 years (2)").CodeName

' Remove all lines from its code module...
With ThisWorkbook.VBProject.VBComponents(StrObjectName).CodeModule
.DeleteLines 1, .CountOfLines
End With

我需要删除第 1-15 行,以便它不再干扰其他代码。

标签: excelvba

解决方案


推荐阅读