Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 465
Default Auto saving sheets from a workbook as separate files.


Hi

I need some help with some VBA code.

My workbook has 50 sheets. Numbered 1 - 50.

I'd like to have a macro save each sheet as a separate file to a path
and in a format specified by response to a popup.

Can someone assist with this?

Grateful for any help.
  #2   Report Post  
Senior Member
 
Location: Hyderabad
Posts: 237
Thumbs up

Quote:
Originally Posted by Colin Hayes View Post
Hi

I need some help with some VBA code.

My workbook has 50 sheets. Numbered 1 - 50.

I'd like to have a macro save each sheet as a separate file to a path
and in a format specified by response to a popup.

Can someone assist with this?

Grateful for any help.
Hi, try this vba ode, you will get popup asking version number: erase the content and enter only version nummber
example: if you want to save as xlsx, then enter only 51
xlsx - 51, xlsm - 52,xls - 56,xlsb - 50. you can play with it and modify accordingly.


'bala sesharao created to save the worksheets as seperate workbooks
Private Sub Workbook_Open()
Call Copy_Every_Sheet_To_New_Workbook

End Sub
Sub Copy_Every_Sheet_To_New_Workbook()
'Working in 97-2007
Dim FileExtStr As String
Dim FileFormatNum As Long
Dim Sourcewb As Workbook
Dim Destwb As Workbook
Dim sh As Worksheet
Dim DateString As String
Dim FolderName As String

With Application
.ScreenUpdating = False
.EnableEvents = False
.Calculation = xlCalculationManual
End With

'Copy every sheet from the workbook with this macro
Set Sourcewb = ThisWorkbook

'Create new folder to save the new files in
DateString = Format(Now, "yyyy-mm-dd hh-mm-ss")
FolderName = Sourcewb.Path & "\" & Sourcewb.Name & " " & DateString
MkDir FolderName

'Copy every visible sheet to a new workbook
For Each sh In Sourcewb.Worksheets

'If the sheet is visible then copy it to a new workbook
If sh.Visible = -1 Then
sh.Copy

'Set Destwb to the new workbook
Set Destwb = ActiveWorkbook

'Determine the Excel version and file extension/format
With Destwb
End With

'Change all cells in the worksheet to values if you want
If Destwb.Sheets(1).ProtectContents = False Then
With Destwb.Sheets(1).UsedRange
.Cells.Copy
.Cells.PasteSpecial xlPasteValues
.Cells(1).Select
End With
Application.CutCopyMode = False
End If
FileFormatNum = InputBox("enter the version number for", "versioning", "xlsx - 51, xlsm - 52,xls - 56,xlsb - 50")





'Save the new workbook and close it
With Destwb
.SaveAs FolderName _
& "\" & Destwb.Sheets(1).Name & FileExtStr, _
FileFormat:=FileFormatNum
.Close False
End With

End If
GoToNextSheet:
Next sh

MsgBox "You can find the files in " & FolderName

With Application
.ScreenUpdating = True
.EnableEvents = True
.Calculation = xlCalculationAutomatic
End With
End Sub


all the best
__________________
Thanks
Bala

Last edited by bala_vb : May 16th 10 at 08:20 AM
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,123
Default Auto saving sheets from a workbook as separate files.

Start here
http://www.rondebruin.nl/copy6.htm

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm



"Colin Hayes" wrote in message ...

Hi

I need some help with some VBA code.

My workbook has 50 sheets. Numbered 1 - 50.

I'd like to have a macro save each sheet as a separate file to a path
and in a format specified by response to a popup.

Can someone assist with this?

Grateful for any help.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Saving just 1 worksheet out of a workbook to a separate file Rich D Excel Discussion (Misc queries) 1 January 23rd 08 02:31 AM
Select sheet tabs in workbook & save to separate workbook files stratocaster Excel Worksheet Functions 2 March 1st 06 03:35 PM
Saving Sheets into Multiple Files becaboo77 Excel Discussion (Misc queries) 4 February 3rd 06 06:10 PM
workbook sheets into separate files markx Excel Worksheet Functions 1 June 28th 05 04:02 PM
How do I save sheets in a workbook to separate files? Omzala Excel Worksheet Functions 2 January 13th 05 06:23 PM


All times are GMT +1. The time now is 07:14 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"