ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Inserting a worksheet into an open workbook via VBA code (https://www.excelbanter.com/excel-programming/331693-inserting-worksheet-into-open-workbook-via-vba-code.html)

manillla

Inserting a worksheet into an open workbook via VBA code
 
I am trying to insert a worksheet from file into an open workbook with VBA
code. I was wandering what the code needs to look like.
Thanks

Norman Jones

Inserting a worksheet into an open workbook via VBA code
 
"manillla" wrote in message
...
I am trying to insert a worksheet from file into an open workbook with VBA
code. I was wandering what the code needs to look like.
Thanks



Hi Manilla

Try something like:

Sub Tester()

Workbooks("Book1.xls").Sheets("YourSheetName").Cop y _
After:=Workbooks("Book2.xls"). _
Sheets(Workbooks("Book2").Sheets.Count)
End Sub

---
Regards,
Norman





Norman Jones

Inserting a worksheet into an open workbook via VBA code
 
Hi Manilla,

Sub Tester()

Workbooks("Book1.xls").Sheets("YourSheetName").Cop y _
After:=Workbooks("Book2.xls"). _
Sheets(Workbooks("Book2").Sheets.Count)
End Sub


should have read:

Sub Tester()

Workbooks("Book1.xls").Sheets("YourSheetName").Cop y _
After:=Workbooks("Book2.xls"). _
Sheets(Workbooks("Book2.xls").Sheets.Count)
End Sub


(The ".xls" was missing from the last instance of "Book2").


---
Regards,
Norman



"Norman Jones" wrote in message
...
"manillla" wrote in message
...
I am trying to insert a worksheet from file into an open workbook with VBA
code. I was wandering what the code needs to look like.
Thanks



Hi Manilla

Try something like:

Sub Tester()

Workbooks("Book1.xls").Sheets("YourSheetName").Cop y _
After:=Workbooks("Book2.xls"). _
Sheets(Workbooks("Book2").Sheets.Count)
End Sub

---
Regards,
Norman








All times are GMT +1. The time now is 12:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com