簡體   English   中英

VBA:在第3行下方復制並粘貼在另一張紙的底部

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

我想復制工作表2第3行以下的所有行,並將它們粘貼到工作表1中的最后一行的下面。我不想像下面一樣使用“ Activesheet”。是否有另一種方法可以做到這一點?

(這不起作用):

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