View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
StargateFanNotAtHome[_2_] StargateFanNotAtHome[_2_] is offline
external usenet poster
 
Posts: 14
Default Split file, saving each tab/worksheet to a new workbook, w/tab asworkbook name?

I had a light-bulb moment this morning to resolve a months-long
problem ... can Excel via a script split up a file by saving each
worksheet to a separate workbook and taking each new workbook's name
from the sheet's original tab name?

I've found a couple of somewhat similar requets he
http://www.ozgrid.com/forum/showthread.php?t=14120, and he
http://groups.google.ca/group/micros...17ee2c1e6a95e2,
where the first one gives me an easier-looking script that seems
potentially more modifiable -- at least, to my less knowledgeable eyes
-- to what needs to be done <g:

--------------------------------------------
Sub Movesheets()
' Macro by WillR
' www.ozgrid.com

Dim oldBook As Workbook
Dim newBook As Workbook


Set oldBook = ActiveWorkbook
Set newBook = Workbooks.Add
newBook.Activate
oldBook. Sheets("Sheet2").Copy after:=newBook.Sheets("Sheet2")
ActiveSheet. Name = "NewSheet"
ActiveWorkbook. SaveAs FileName:=Format( Date, "MMMMYY") &
"Report.xls"
--------------------------------------------

Of course, the difference is that this one saves only sheet 2 to a new
workbook and gives it a specific name where I need all the worksheets
to be saved to new, individual workbooks and to have them named by
their sheet name.

Thanks! :oD