Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I am using the following code to split one workbook with multipl 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' actually work - it replicates the original. Could i ask for some help optimising the code please! thanks, Hamis -- Message posted from http://www.ExcelForum.com |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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/ |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() -- 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/ |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Bob,
Seems to work alright for the first three sheets then runtime error occurs on the copy of worksheet. any ideas? --- Message posted from http://www.ExcelForum.com/ |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hamish,
I just tried it with 7 worksheets, and all 7 were saved fine. Nothing off the top, I'll post back if I think of anything. -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "HamishM " wrote in message ... Thanks Bob, Seems to work alright for the first three sheets then runtime error occurs on the copy of worksheet. any ideas? --- Message posted from http://www.ExcelForum.com/ |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Bob,
this is the code i'm using..... Sub SplitSheets() Dim W As Worksheet Application.ScreenUpdating = False Application.DisplayAlerts = False For Each W In Worksheets W.Copy ActiveWorkbook.SaveAs Filename:=ThisWorkbook.Path & "/" & W.Name ActiveWorkbook.Close Next W Application.DisplayAlerts = True Application.ScreenUpdating = True End Su -- Message posted from http://www.ExcelForum.com |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Yeah, it's identical.
-- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "HamishM " wrote in message ... Bob, this is the code i'm using..... Sub SplitSheets() Dim W As Worksheet Application.ScreenUpdating = False Application.DisplayAlerts = False For Each W In Worksheets W.Copy ActiveWorkbook.SaveAs Filename:=ThisWorkbook.Path & "/" & W.Name ActiveWorkbook.Close Next W Application.DisplayAlerts = True Application.ScreenUpdating = True End Sub --- Message posted from http://www.ExcelForum.com/ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
split post code (zip code) out of cell that includes full address | Excel Discussion (Misc queries) | |||
Another VB Code Required | Excel Discussion (Misc queries) | |||
VB Code Required | Excel Discussion (Misc queries) | |||
Improved printing of VBA code? | Excel Programming | |||
Improved printing of VBA code? | Excel Programming |