View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Split Workbook - improved code required

Hamish,

Give this a try

Dim W As Worksheet
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For Each W In Worksheets
W.Copy
ActiveWorkbook.SaveAs Filename:=ThisWorkbook.Path & "/" & W.Name
activeworkbok.Close
Next W
Application.DisplayAlerts = True
Application.ScreenUpdating = True


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"HamishM " wrote in message
...
Hi,

I am using the following code to split one workbook with multiple
worksheets into - many workbooks.


Sub SplitSheets()
Dim W As Worksheet
For Each W In Worksheets
W.SaveAs ActiveWorkbook.Path & "/" & W.Name
Next W
End Sub


The problem i have is this takes several minutes to run and it doesn't
actually work - it replicates the original.

Could i ask for some help optimising the code please!

thanks,
Hamish


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