![](/img/trans.png)
[英]How to copy a dynamic range of cell from another workbook, paste it to another one?
[英]How to copy a range of cell from another workbook and paste it to another one?
每次第三方向我發送他輸入的更新版本時,我都需要更新我的主文件。 因此,我需要將此新輸入的范圍復制粘貼到我計算機上保存的工作簿中。 如果 A 列中的值大於 0,則范圍需要包括所有列和所有行。例如,在下圖中,從 A1 到 A45。
在此處輸入圖像描述
我找到了一種方法來 select 行並停在第一個零處。 我在代碼 i 中調用的一側放了一個求和乘積公式。
現在,我有這個代碼:
我在 Set wb2 = Workbooks("20200403 Selina - Loanbook V2.09 (1).xls")
我無法修復它...我已經嘗試過 ThisWorkbook 但沒有,你知道嗎?
讓我知道:)
安托萬
Sub CopyPaste()
Dim wb1 As Workbook
Dim wb2 As Workbook
'Open Workbook from Pepper
Set wb1 = Workbooks.Open("G:\Shared drives\Reporting\Power BI Source Files- DO NOT TOUCH\Pepper Automation\Accounts latest\Accounts updated\Accounts_latest.xlsx")
'Copy Range (Column A to BW - all filled rows)
Dim i As Integer
i = Worksheets("Accounts_latest").Range("CA1").Value
wb1.Worksheets("Accounts_latest").Range("A1:BW" & i).Copy
'Paste to worksheet in workbook2:
Set wb2 = Workbooks("20200403 Selina - Loanbook V2.09 (1).xls")
wb2.Activate
wb2.Sheets("Pepper Accounts RAW").Range("A1").PasteSpecial Paste:=xlPasteValues
Range("A1").Select
'Close workbook
wb1.Close savechanges:=True
Application.DisplayAlerts = True
End Sub
像這樣的東西
Set wb2 = Workbooks.Open("20200403 Selina - Loanbook V2.09 (1).xls")
wb2.Close savechanges:=True
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.