?
Solved

Save Excel as individual workbook

Posted on 2016-08-23
6
Medium Priority
?
40 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 18

Accepted Solution

by:
xtermie earned 2000 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 2000 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 18

Assisted Solution

by:xtermie
xtermie earned 2000 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

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!

Question has a verified solution.

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

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

770 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