ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   moving worksheet to another workbook (https://www.excelbanter.com/excel-programming/305400-moving-worksheet-another-workbook.html)

JohnE

moving worksheet to another workbook
 
Is it possible to move a worksheet from one workbook to
another? I have a workbook that acts like a main form.
During usage, it may become necessary to bring into the
workbook a sheet from another workbook. So, if it is
possible, how is something like that done? Or would I be
better off using a different method?
Thanks.
*** John

Nick Hodge

moving worksheet to another workbook
 
John

This code will open a workbook called test and move a sheet in it, also
called test to the first sheet in the workbook that contains the code

Sub bringFromOtherBook()
Dim wb As Workbook
Dim sht As Worksheet
Set wb = Workbooks.Open("C:\Test.xls")
Set sht = wb.Worksheets("Test")
sht.Move Befo=ThisWorkbook.Worksheets(1)
wb.Close SaveChanges:=False
Set sht = Nothing
Set wb = Nothing
End Sub


--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
HIS


"JohnE" wrote in message
...
Is it possible to move a worksheet from one workbook to
another? I have a workbook that acts like a main form.
During usage, it may become necessary to bring into the
workbook a sheet from another workbook. So, if it is
possible, how is something like that done? Or would I be
better off using a different method?
Thanks.
*** John





All times are GMT +1. The time now is 11:26 PM.

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