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
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.