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
Solved

Save Excel as individual workbook

Posted on 2016-08-23
6
36 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
stuck in average-1 12 65
Time difference between dates without weekend 33 72
Sumif Function with nested left function? 4 35
vba to flip column 14 17
Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvieā€¦
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

809 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