[英]How can I copy data from one sheet to another sheet in Excel 2007 using a macro?
I am using MS Office 2007. How can I copy whole data from sheet one to sheet two? 我正在使用MS Office2007。如何将整个数据从第一张复制到第二张? I want to copy the whole data from row 5 to onward in sheet two. 我想将整个数据从第5行复制到第二页的开头。 The whole scenario is given below in detail. 整个方案在下面详细给出。
Sheet one: 第一页:
Copy the data from column B and Row 3 复制B列和第3行中的数据
Sheet Two: 第二页:
Paste the Copied Data in Column B and Row 3 将复制的数据粘贴到B列和第3行中
Sheet One: 第一张:
Copy the whole data from Column B to Column G and Row 5 to onward 将整个数据从B列复制到G列,然后将第5行复制到前面
Sheet Two: 第二页:
Paste whole copied data in sheet two from last filled row to onward 从最后填充的行到第二行将整个复制的数据粘贴到第二页中
Data doesn't overwrite on any row or column. 数据不会在任何行或列上覆盖。 Every data will be added in sheet two from sheet one when macro will be run. 运行宏时,每个数据将从第一页添加到第二页。
The best way to learn how to do this is to record a macro. 学习如何执行此操作的最佳方法是记录宏。 Excel has a very good macro recorder. Excel具有非常好的宏记录器。 Just start to record a new macro, then manually perform all the steps you describe in your question. 刚开始记录一个新的宏,然后手动执行您在问题中描述的所有步骤。 After you have finished, stop the macro recorder and take a look at the code that Excel generated for you. 完成后,停止宏记录器,并查看Excel为您生成的代码。
Alt+F11 is the shortcut key to get to the VBA code editor in Excel. Alt + F11是进入Excel中的VBA代码编辑器的快捷键。
This should do the trick. 这应该可以解决问题。 But before you try, do a SaveAs to a different file, so if it doesn't give the desired results you can go back to the other version. 但是,在尝试之前,请对其他文件执行SaveAs操作,因此,如果未提供所需的结果,则可以返回到其他版本。 There are no Undos with macros. 没有宏撤消。
Sub CopyInfo()
Sheet2.Range("B3").Value = Sheet1.Range("B3").Value
Sheet1.Range("B5:G65000").Copy
Sheet2.Range("B5").Paste
Application.CutCopyMode = False
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.