将整个工作表复制到Excel 2010中的新工作表 [英] Copy an entire worksheet to a new worksheet in Excel 2010

查看:228
本文介绍了将整个工作表复制到Excel 2010中的新工作表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现了类似的问题,处理在一个工作簿中复制整个工作表并将其粘贴到另一个工作簿,但我有兴趣简单地复制整个工作表并将其粘贴到新的工作表 - 在同一个工作簿中。



我正在将2003年.xls文件转换为2010年.xlsm,用于在工作表之间复制和粘贴的旧方法不会粘贴正确的行高。我的初始解决方法是循环遍历每一行,并从我正在复制的工作表中抓取行高,然后循环遍历,并将其粘贴到工作表中的行高度中插入这些值,但这种方法的问题是工作表包含生成新行的按钮,它们更改行编号和工作表的格式,使所有行不能只是一个宽度。



我真正想要做的只是简单地复制整个工作表并粘贴它。以下是2003版本的代码:

  ThisWorkbook.Worksheets(Master)。Cells.Copy 
newWorksheet我们感到惊讶的是,转换为.xlsm是导致此现象的一个突破。任何建议或想法都会很棒。

解决方案

只需运行如下所示的精确副本将其复制到最后一张表

  Sub Test()
Dim ws1 As Worksheet
设置ws1 = ThisWorkbook.Worksheets Master)
ws1.Copy ThisWorkbook.Sheets(Sheets.Count)
End Sub


I have found similar questions that deal with copying an entire worksheet in one workbook and pasting it to another workbook, but I am interested in simply copying an entire worksheet and pasting it to a new worksheet -- in the same workbook.

I'm in the process of converting a 2003 .xls file to 2010 .xlsm and the old method used for copying and pasting between worksheets doesn't paste with the correct row heights. My initial workaround was to loop through each row and grab the row heights from the worksheet I am copying from, then loop through and insert those values for the row heights in the worksheet I am pasting to, but the problem with this approach is that the sheet contains buttons which generate new rows which changes the row numbering and the format of the sheet is such that all rows cannot just be one width.

What I would really like to be able to do is just simply copy the entire worksheet and paste it. Here is the code from the 2003 version:

ThisWorkbook.Worksheets("Master").Cells.Copy
newWorksheet.Paste

I'm surprised that converting to .xlsm is causing this to break now. Any suggestions or ideas would be great.

解决方案

It is simpler just to run an exact copy like below to put the copy in as the last sheet

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

这篇关于将整个工作表复制到Excel 2010中的新工作表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆