View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default Copy worksheets into new file

To add the sheets to a new file, add this to the code:

Dim myNewBook As Workbook
Set myNewBook = Workbooks.Add

and then change

ActiveWindow.SelectedSheets.Move _
After:=ThisWorkbook.Sheets(1)
to
ActiveWindow.SelectedSheets.Move _
After:=myNewBook.Sheets(1)

To rename the sheet to a value on the sheet itself (say, in cell A2) change

Worksheets(myShtName).Name = _
Replace(ActiveWorkbook.Name, ".xls", "")
to
Worksheets(myShtName).Name = _
Worksheets(myShtName).Range("A2").Value

HTH,
Bernie
MS Excel MVP

"rglasunow " wrote in message
...
Thanks to you both. Both ways worked. However, I want it to save the
tabs into a new workbook outside the one the macro is running in. I've
been trying different varities to the code and I can't get it to create
a new file to save the tabs into.

Also do you know if it is possible to name each tab to a cell in each
tab?

Thank you very much!


---
Message posted from http://www.ExcelForum.com/