Excelmacros:将工作表复制并粘贴到另一个工作表中

我已经能够制作工作表的精确副本,并将其添加到工作簿:

Sub Test() Dim ws1 As Worksheet Set ws1 = ThisWorkbook.Worksheets("Detailed List") ws1.Copy ThisWorkbook.Sheets(Sheets.Count) End Sub 

但我试图将复制的工作表粘贴在另一个工作表上。 例如,我试图复制工作表“详细列表”,并粘贴并覆盖“testing表”,但是我能够用上面的代码完成另一个工作表。 任何帮助将是伟大的。

你几乎已经拥有了,而你自己的解决scheme是有效的……但是,在完整性的努力中……

 Sub Test() Dim ws1 As Worksheet Dim ws1Copy As Worksheet Set ws1 = ThisWorkbook.Worksheets("Detailed List") ws1.Copy ThisWorkbook.Sheets(Sheets.Count) 'we can't set the copied object directly to a varaiable, but it becomes the active sheet by default Set ws1Copy = ActiveSheet 'assign the newly copied activesheet to a variable Application.DisplayAlerts = False 'supress warnings, the delete method gives the user a warning Sheets("Testing Sheet").Delete 'delete the testing sheet Application.DisplayAlerts = True 'un-supress the warnings ws1Copy.Name = "Testing Sheet" 'change the name of the copied sheet to the testing sheet. End Sub 

所以我最终这样做了:

 Worksheets("Detailed List").Range("A7").CurrentRegion.Copy Worksheets("Detailed Copy").Range("A7").PasteSpecial 

我在开始运行macros之前,首先复制了详细列表。 然后突出显示所有数据点和标题,并覆盖副本。 我需要这样做,因为我正在制作一个macros,当有人改变“详细列表”中的一个单元格时,我需要显示曾经在单元格中的旧值,所以通过基本上有两个列表副本,可以先进行比较,然后只是一遍又一遍地复制列表,所以它会自动更新自己以做出任何更改。