简体   繁体   English

VBA:在第3行下方复制并粘贴在另一张纸的底部

[英]VBA: Copy below row 3 and paste at the bottom of another sheet

I want to copy all rows below Row 3 in sheet2 and paste them below the last row in sheet 1. I don't want to use 'Activesheet" like I have below. Is there another way to accomplish this? 我想复制工作表2第3行以下的所有行,并将它们粘贴到工作表1中的最后一行的下面。我不想像下面一样使用“ Activesheet”。是否有另一种方法可以做到这一点?

(This doesn't work): (这不起作用):

Rows("3:3").Select
Range(Selection, Selection.End(x1Down)).Select
Selection.Copy

Sheets("sheet1").Select
Range(Selection, Selection.End(x1Down)).Select
ActiveSheet.Paste
Dim ws as Worksheet
Set ws = Worksheets("mySheet") 'change name as needed

With ws
   'assumes data is in a "table" format with all data rows in column A and data columns in row 1
   Dim lRow as Long, lCol as Long
   lRow = .Range("A" & .Rows.Count).End(xlUp).Row 
   lCol = .Cells(1,.Columns.Count).End(xlToLeft).Column

   .Range(.Range("A4"),.Cells(lRow,lCol)).Copy _
    Worksheets("Sheet1").Range("A" & .Rows.Count).End(xlUp).Offset(1)

End With

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

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