Beneindias
Board Regular
- Joined
- Jun 21, 2022
- Messages
- 120
- Office Version
- 365
- Platform
- Windows
- MacOS
Hi all,
I have made a macro in excel to copy a worksheet from another workbook without opening that second workbook, but this code only worked the first time.
The plan is to copy "Folha1" from "Lista Obras" workbook and copy it as last worksheet in the currently opened workbook, without opening "Lista Obras".
This code worked the first time I tried it.
I can copy the worksheet manually.
Can anybody help me with this?
Thank you all
I have made a macro in excel to copy a worksheet from another workbook without opening that second workbook, but this code only worked the first time.
VBA Code:
Sub CopySheetFromClosedWB()
Application.ScreenUpdating = False
Set closedBook = Workbooks.Open("C:\Users\RubenDias\Desktop\Mapas Ajudas de Custo\Lista Obras.xlsx")
closedBook.Sheets("Folha1").Copy After:=Sheets("Folha1")
closedBook.Close SaveChanges:=False
Application.ScreenUpdating = True
End Sub
The plan is to copy "Folha1" from "Lista Obras" workbook and copy it as last worksheet in the currently opened workbook, without opening "Lista Obras".
This code worked the first time I tried it.
I can copy the worksheet manually.
Can anybody help me with this?
Thank you all