![](/img/trans.png)
[英]Using macro to copy multiple ranges from one sheet, and paste them into another sheet in the first empty row
[英]Excel Macro Copy paste into another xls file in the first empty row
我目前正在從事一個數字項目,我必須分析 100 多個 FB excel 文件中的數據。
我的分析過程的一部分包括從始終相同的特定單元格中提取數據。
正如您所理解的,我想制作一個宏以避免無用的時間浪費。
我知道如何在文件中提取它,但我想調整我的宏以便將它復制到另一個文件中。
我的代碼如下:
***范圍(“A9:D9”)。選擇
選擇.復制
Windows(“test2.xlsx”)。激活
ActiveSheet.Paste***
現在我想將數據粘貼在一個空行中,以便有數百行一個在另一個(每個 FB 提取物一個)。
有人會給我正確的代碼以避免浪費大量時間嗎?
如果宏在“摘要”工作簿中並且 FB 文件已打開並處於活動狀態:
ActiveSheet.Range("A9:D9")Copy _
ThisWorkbook.Sheets("Data").Cells(Rows.Count,1).End(xlup).offset(1,0)
這是我用於類似操作以選擇下一個可用單元格的代碼片段。
'Insert after Your Windows("test2.xlsx").Activate in place of your paste Code.....
'This gives you the variable for the last cell with a value
lastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
'This section selects the next cell below your last used cell and pastes the information.
ActiveSheet.Range("A" & lastRow + 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Rest of Code....
我希望這就是你要找的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.