Solved

Save Excel as individual workbook

Posted on 2016-08-23
6
37 Views
Last Modified: 2016-09-14
Hello EE,

Can someone please help me with excel macro to save excel tabs as individual workbooks?  My large excel file has formulas and charts.  I will like a macro to copy and paste values prior to saving as individual workbooks into the same path.

Thanks in advance for your help.
0
Comment
Question by:fb1990
  • 4
  • 2
6 Comments
 
LVL 18

Accepted Solution

by:
xtermie earned 500 total points (awarded by participants)
ID: 41766539
Sub CreateWorkbooks()
'Creates an individual workbook for each worksheet in the active workbook.
Dim wbDest As Workbook
Dim wbSource As Workbook
Dim sht As Object 'Could be chart, worksheet, Excel 4.0 macro,etc.
Dim strSavePath As String

On Error GoTo ErrorHandler

Application.ScreenUpdating = False 'Don't show any screen movement

strSavePath = "C:\Temp\" 'Change this to suit your needs

Set wbSource = ActiveWorkbook

For Each sht In wbSource.Sheets
 sht.Copy
 Set wbDest = ActiveWorkbook
 wbDest.SaveAs strSavePath & sht.Name
 wbDest.Close 'Remove this if you don't want each book closed after saving.
Next

Application.ScreenUpdating = True

Exit Sub

ErrorHandler: 'Just in case something hideous happens
MsgBox "An error has occurred. Error number=" & Err.Number & ". Error description=" & Err.Description & "."
End Sub

Open in new window

0
 
LVL 18

Assisted Solution

by:xtermie
xtermie earned 500 total points (awarded by participants)
ID: 41766544
Macro to copy and paste values in each worksheet in a workbook is provided here:
https://www.experts-exchange.com/questions/27808846/Macro-to-copy-paste-special-values-all-sheets-in-workbook.html

I think you should use the code proposed by Elton Pascua but comment out a few lines
Sub test()
    
    Dim wb As Workbook
    Dim ws As Worksheet
    Dim rngFormulas As Range
    
    Set wb = ThisWorkbook

    Application.ScreenUpdating = False
        
    'For Each ws In wb.Worksheets
    '     ws.Unprotect "xxxx"
    '    ws.Calculate
    'Next ws
        
    Application.Calculation = xlCalculationManual
        
    For Each ws In wb.Worksheets
        On Error Resume Next
        ws.Cells.Copy
        ws.Cells.PasteSpecial xlPasteValues
    Next ws
        
    'wb.Worksheets("Data").Delete
    'wb.Worksheets("Mapping").Delete
    'wb.Worksheets.Copy
        
End Sub

Open in new window

Use that prior to running the macro above

Hope this helps!
0
 
LVL 1

Author Comment

by:fb1990
ID: 41766773
xtermie, thanks for the solution.  Is there a way to just save the spreadsheet out after the paste value and not take away my formulas from the master file?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 18

Assisted Solution

by:xtermie
xtermie earned 500 total points (awarded by participants)
ID: 41766845
The formula should not be taken away...hmm...yes, we are using a SAVEAS for each of the worksheets in the first macro...but in the second one there is no save...try this for copying-pasting the values and saving the initial file as something with values only:

Sub copypastevalues()
    Dim wb As Workbook
    Dim ws As Worksheet
    Dim rngFormulas As Range
    Dim strSavePath As String
    
    Set wb = ThisWorkbook
    strSavePath = "C:\Test\"
    strFileName = "ValuesOnly.xlsx"
    
    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual
        
    For Each ws In wb.Worksheets
        On Error Resume Next
        ws.Cells.Copy
        ws.Cells.PasteSpecial xlPasteValues
    Next ws
            
    wb.SaveAs strSavePath & strFileName
        
End Sub

Open in new window

0
 
LVL 18

Expert Comment

by:xtermie
ID: 41793905
Good comment and suggestions provided but not feedback on final outcome or awarding of point from the author
0
 
LVL 1

Author Comment

by:fb1990
ID: 41798471
Hello xtermie,

Please accept my apology.  I have been out of pocket for a while now.  I needed to award the point and close the request.  I can't seem to find where to do that
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question