英文:
Copy/paste from another workbook
问题
这是我的代码:
Dim chemin As String
Workbooks.Open ("Z:\ext_Workbook.xlsx")
Sheets("produits").Activate
Sheets("produits").Range("A1:CZ500").Copy
ThisWorkbook.Activate
Sheets("STT").Select
ActiveSheet.Range("A1").Select
ActiveSheet.Paste
Application.DisplayAlerts = False
Workbooks("ext_Workbook.xlsx").Close
运行停在这行:
Sheets("STT").Select
但是我已经验证了,有一个名为STT的工作表,拼写也是相同的。
英文:
It is a simple task, but I don't know why it is not working…
This is my code :
Dim chemin As String
Workbooks.Open ("Z:\ext_Workbook.xlsx")
Sheets("produits").Activate
Sheets("produits").Range("A1:CZ500").Copy
ThisWorkbook.Activate
Sheets("STT").Select
ActiveSheet.Range("A1").Select
ActiveSheet.Paste
Application.DisplayAlerts = False
Workbooks("ext_Workbook.xlsx").Close
The run stop at the line :
Sheets("STT").Select
But I verified, and there is a sheet named STT, with the same spelling
答案1
得分: 0
以下是翻译好的部分:
下面的代码应该适用于您:
Dim SourceWBK As Workbook, DestinationWBK As Workbook
Set SourceWBK = Workbooks.Open("Z:\ext_Workbook.xlsx")
Set DestinationWBK = ThisWorkbook
SourceWBK.Worksheets("produits").Range("A1:CZ500").Copy
DestinationWBK.Worksheets("STT").Range("A1:CZ500").PasteSpecial Paste:=xlPasteAll
Application.CutCopyMode = False
Application.DisplayAlerts = False
SourceWBK.Close False
希望这对您有帮助。
英文:
The below should work for you.
Dim SourceWBK As Workbook, DestinationWBK As Workbook
Set SourceWBK = Workbooks.Open("Z:\ext_Workbook.xlsx")
Set DestinationWBK = ThisWorkbook
SourceWBK.Worksheets("produits").Range("A1:CZ500").Copy
DestinationWBK.Worksheets("STT").Range("A1:CZ500").PasteSpecial Paste:=xlPasteAll
Application.CutCopyMode = False
Application.DisplayAlerts = False
SourceWBK.Close False
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论