Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Save Excel as individual workbook

Posted on 2016-08-23
6
Medium Priority
?
41 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
Industry Leaders: 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 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

618 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