excel computer course london - save sheets as indevidual
Microsoft Office Training verified by visa - mastercard securecode about microsoft training company london ukadd this page to your favourites/bookmarksAdd to favourites
view a printable version of this pagePrintable version
email this page to somebodyEmail this page
Customer: Sign in
Delegate: Sign in
Trainer: Log in

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and Help » excel computer course london - Save Sheets As Indevidual Files

excel computer course london - Save Sheets As Indevidual Files

The UK's most regular instructor-led training courses.
Training information: excel computer course london · Microsoft excel training · VBA courses London UK

resolvedResolved · Low Priority · Version Standard

Save Sheets As Indevidual Files

David has attended:
Excel VBA course

by - delegate David [3 posts] (2007 Oct 22 Mon, 16:33) replyReply

What code should I use If I want to save each sheet in a workbook as an individual File.

Cheers!

Excel Intermediate 1 day course
Version Date Location Places
available
Book Next place rate:
Card Invoice
2003 2008 Sep 9 Tue Bloomsbury 2 book now £215 £215
2002/XP 2008 Sep 9 Tue Tooting 0 FULL    
2003 2008 Sep 11 Thu Southwark 4 book now £207 £215
2002/XP 2008 Sep 16 Tue Tooting 0 FULL    
2003 2008 Sep 16 Tue Bayswater 4 book now £195 £205
2003 2008 Sep 18 Thu Bloomsbury 2 book now £215 £215
Full Schedule: See all 137 Excel Intermediate course dates.
Bookings currently available until 25th November 2009.

RE: Save Sheets As Indevidual Files

by - trainer Carlos gold contributer[413 posts] (2007 Oct 24 Wed, 11:03) replyReply

David

Could you clarify this further.

Do you want save the worksheet as a separate New Workbook or just save the worksheet within the workbook without saving the rest of the workbook

Carlos

RE: Save Sheets As Indevidual Files

by - trainer Carlos gold contributer[413 posts] (2007 Oct 24 Wed, 11:45) replyReply

David

Further to the above you cannot save a worksheet separately within a workbook. You need to save the whole workbook.

To separate sheets within a workbook into separate individual workbooks do the following code:

Sub SaveSheetsSeparately()

Dim NoSheets As Integer
Dim i As Integer

NoSheets = Sheets.Count

For i = 1 To NoSheets
Sheets(i).Activate
ActiveSheet.Copy
ActiveWorkbook.SaveAs Filename:="C:\" & ActiveSheet.Name & ".xls"
ActiveWorkbook.Close
Next i

End Sub


In the code the ActiveSheet.copy command is not like copy and paste.
It creates a copy of the active sheet, in a new workbook.
The new workbook is then saved, thus saving all the sheets as new separate workbooks.

You can adapt the code to save just one sheet by removing the For loop.

Hope this helps

Carlos

RE: Save Sheets As Indevidual Files

by - delegate David [3 posts] (2007 Oct 25 Thu, 11:27) replyReply

Thanks Carlos,

From you original code I ended up with,

Sub SaveSheetsSeparately()
Application.ScreenUpdating = False

Dim i As Long
Dim FName As Variant
Dim varOpenFile As Variant
Dim Response As Byte

On Error GoTo EH

MsgBox "Please open the workbook you wish to save the sheets from."

varOpenFile = Application.GetOpenFilename
Workbooks.Open Filename:=varOpenFile, _
UpdateLinks:=0

With ActiveWorkbook
For i = 1 To Worksheets.Count
If .Worksheets(i).Visible = xlSheetVisible Then
Sheets(i).Activate
ActiveSheet.Copy
Response = MsgBox("Do you want to save " & ActiveSheet.Name & "?" _
, 292, "Totals")

If Response = vbNo Then
ActiveWorkbook.Close savechanges:=False
Else
FName = Application.GetSaveAsFilename(InitialFileName:=ActiveSheet.Name, _
filefilter:="Excel Files (*.xls), *.xls", _
Title:="SaveAs")

If FName = False Then
MsgBox ActiveSheet.Name & " will not be saved because you pressed Cancel." _
& vbCrLf & "You will now move onto the next sheet."
ActiveWorkbook.Close savechanges:=False
Else
ActiveWorkbook.Saveas Filename:=FName
ActiveWorkbook.Close
End If
End If
End If
Next i

End With
ActiveWorkbook.Close savechanges:=False
MsgBox "Your Report is Split. Congrats!" _
& vbCrLf & "Now go thank Dave Pilbeam for saving 10 minutes of your life! "

Exit Sub

EH:

If Err.Number = 1004 Then
MsgBox "You didn't choose a report. This application will now close, and you can then try again."
Else
MsgBox "Whoo Nelly!!! Don't know what's gone wrong but this might help... Type: " _
& Err.Number & vbCrLf & Err.Description

End If

End Sub

I needed it to ignore hiden sheets and ask where you wanted to save them, plus deal with the errors. Hopefully I got them all.

Thanks agian Carlos, I think this training will make a real difference in my work.


Related articles

· Database Tips from an Excel Training Course
· How Excel Training Can Improve Your Company's Sales Process
· Tools From Advanced Excel Courses: Goal Seek and Solver
· Do You Really Need Excel VBA Training?
· 3 Reasons Why Excel Training Courses For Employees Can Improve Your Business

Excel tip:

Copying the same value, label or formula quickly into a range of selected cells.

Select your range of cells. Type the value, label or formula that you want to appear in all the selected cells and then press Ctrl+Enter.

View all Excel hints and tips

Institute of IT Training - Accredited Training Provider Microsoft Certified Partner
microsoft office
Microsoft Office Specialist Authorised Testing Centre (MOS and MCAS)

Prodigy Platinum Learning Partner

Institute of IT Training - Accredited Training Provider Association of Computer Trainers Valid HTML 4.01 Transitional
Valid CSS Markup

secure online payments - visa - mastercard

Mini sitemap. These are the main areas of our web site. Full sitemap.

Training by application Main information pages See also

Access courses
DreamWeaver courses
Excel courses
MS Project courses
Outlook courses
PowerPoint courses
VBA courses
Word courses
(more...)

Public scheduled courses
On-site training
Closed company courses

Microsoft Office training
Pricing and availability
Training schedule
Training venues

Access training
Dreamweaver training
Excel training
MS Project training
PowerPoint training

London Computer Training
Computer Training London

Microsoft Access training
Microsoft Excel training
Microsoft Project training
Microsoft Outlook training
Microsoft Powerpoint training
Microsoft Word training

Time Management Course London

Interested in Access training? Please see the following pages:
microsoft access courses · microsoft training access course
microsoft+access+training · access courses in london

Training Information
AddThis Social Bookmark Button What's this?
Add to Del.icio.us Add to Facebook Add to Digg Add to Reddit Add to Google Add to Yahoo Add to Diigo Add to Mr. Wong Add to Linkarena Add to Power Oldie Add to Folkd Add to Jumptags Add to Upchuckr Add to Simpy Add to StumbleUpon Add to Slashdot Add to Netscape Add to Furl Add to Spurl Add to Blinklist Add to Blogmarks Add to Technorati Add to Newsvine Add to Blinkbits Add to Ma.Gnolia Add to Smarking Add to Netvouz