简体   繁体   English

Excel:将多个行和列从一个工作表复制并粘贴到另一个工作表

[英]Excel : Copy and paste multiple rows and columns from one worksheet to another

i would like to copy multiple rows from one worksheet to another , i have data starting in one worksheet at A2 row and ends at A108850 and it starts at A2 column and ends at I2 column , how can i copy all that data into another worksheet where row starts with A4 and column starts with A4 and ends with I4. 我想将多个行从一个工作表复制到另一个工作表,我的数据从一个工作表开始在A2行,结束于A108850,它从A2列开始,在I2列结束,我如何将所有这些数据复制到另一个工作表中,行以A4开头,列以A4开头,以I4结尾。

How could i possibly do it through some macro?. 我怎么可能通过某个宏呢?

Thanks. 谢谢。

Try this 尝试这个

Worksheets("Sheet1").Range("A2:I108850").Copy Worksheets("Sheet2").Range("A4")

Change the range reference and worksheet's name accordingly. 相应地更改范围引用和工作表的名称。

Copy&Paste is an "expensive" operation, the greater the range the more expensive the operation 复制粘贴是一项“昂贵”的操作,范围越大,操作越昂贵

Should you be interested in values only, you could try this: 如果您仅对值感兴趣,则可以尝试以下操作:

    Worksheets("DestinationSheetName").Range("A2:I108850").Value = Worksheets("SourceSheetName").Range("A2:I108850").Value

edited after OP's comment 在OP评论后编辑

Should the code in your last comment have the same aim of pasting values only, then change the second statement into the following: 如果您最后一个注释中的代码具有仅粘贴值的相同目的,则将第二条语句更改为以下内容:

    With Worksheets("Sheet1").Range("A2:I108850") '<--| reference the "source" range you want to paste values from
         .Range("A4").Resize(.Rows.Count, .Columns.Count).Value = .Value '<--| resize "destination" range accordingly to "source" one and paste values into it
    End With

of course you must check for sheet names to be valid ones for the currently active workbook 当然,您必须检查工作表名称是否对当前活动的工作簿有效

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM