简体   繁体   English

仅复制最后一行

[英]Copy only last row

have a macro that Copies complete columns to another sheet. 有一个宏,可以将完整的列复制到另一个工作表。

Currently though, I need a Macro to only copy the last ROW with data 目前,尽管如此,我需要一个宏才能仅复制包含数据的最后一个ROW

Example, If i have the following: 例如,如果我有以下情况:

Cell A1 = 1, Cell A2 = 2, Cell A3 = 3, Cell A4 = Sum (A1:A3),Cell A5 = Blank 单元格A1 = 1,单元格A2 = 2,单元格A3 = 3,单元格A4 =总和(A1:A3),单元格A5 =空白

I want the macro to only copy A4. 我希望宏仅复制A4。 I am doing this for entire columns (A to E) Thanks 我正在整列(A到E)中执行此操作,谢谢

Someone already helped me with the below code, which copies all data till the last row, excluding the last row. 有人已经通过以下代码帮助了我,该代码将所有数据复制到最后一行(不包括最后一行)。 I need it to do the opposite, only copy the last row 我需要做相反的事情,只复制最后一行

Dim lrow As Long

With wbk4.Sheets("Sheet1")
lrow = .Range("A" & .Rows.Count).End(xlUp).Row
.Range("A1", "E" & lrow - 1).Copy
wbk2.Sheets("Sheet1").Range("XD1").PasteSpecial xlPasteAll
End With

Just through quickly checking through the code, would it be: 只要快速检查一下代码,它就会是:

.Range("A1", "E" & lrow - 1).Copy

Changed to: 变成:

.Range("A" & lrow - 1, "E" & lrow).Copy

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

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