![](/img/trans.png)
[英]Excel 2007 VBA: How do I copy and paste from a dynamic range on one sheet to the first empty row of another sheet?
[英]Copy a range from one sheet to the first empty row from another sheet
在Excel工作表中,我插入了一個執行宏的按鈕。 這是宏的代碼:
Sub Button1_Click()
'
' Button1_Click Macro
'
' Keyboard Shortcut: Option+Cmd+y
'
Range("A17:I34").Select
Selection.Copy
Sheets("ITEMS CONTROL").Select
Range("A7").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("A3:I9").Select
End Sub
源工作表是“ ORDEN DE COMPRA”,我要復制所選范圍的工作表是“ ITEMS CONTROL”。
我需要將選定范圍中的非空行復制到末頁的第一個空行中,而不是復制到當前代碼中的范圍中。
謝謝
這行得通嗎?
Sub Button1_Click()
'This will select the whole range of cells starting in A17
Sheets("ORDEN DE COMPRA").Select
Range(Range("A17"), Range("A17").End(xlDown).End(xlToRight)).Copy
'Now we need to find the first free row in the next sheet, assuming all rows have something on column A
Sheets("ITEMS CONTROL").Select
Range("A1").End(xlDown).Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
End Sub
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.