Solved

Exporting individual Excel sheets to individual files

Posted on 2011-02-28
5
356 Views
Last Modified: 2012-06-27
My supervisor was wondering when in a workbook, could you export the individual sheet to its own file? Instead of copying and pasting all of the values?
0
Comment
Question by:danisham
  • 2
  • 2
5 Comments
 
LVL 9

Accepted Solution

by:
McOz earned 250 total points
ID: 35000560
This code will save the active sheet as a new workbook, "Book2.xlsx". You can just tweak the filename/path to suit.

To do it without code, just right-click on the sheet tab, choose "Move or Copy", and choose "(new book)" in the "To Book" drop-down. Tick the "Create a copy" checkbox to keep the original sheet in place as well.

Good luck!
Sub SaveActiveSheet()
    ActiveSheet.Move
    ActiveWorkbook.SaveAs Filename:="G:\Book2.xlsx", FileFormat:= _
        xlOpenXMLWorkbook, CreateBackup:=False
End Sub

Open in new window

0
 
LVL 22

Expert Comment

by:rspahitz
ID: 35003089
You can simply save the file as a txt or csv file and, aside from a warning, the current sheet will be exported.  However, this will only be values.

If you want to move/copy the sheet, open the second workbook then in the first, right-click on the tabs at the bottom and and pick "Move or Copy", in the dropdown, pick the other workbook, then pick a place to move it to (for a copy, check the box at the bottom.)
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 35003097
sorry...the copy/move was mentioned by mcOz...so only export to a new format if you want values but not formulas.
0
 

Author Closing Comment

by:danisham
ID: 35006747
Thanks McOz! I should have tried the obvious move / copy solution but didn't have time to fool around with the problem. May I ask where I would insert that code?
0
 
LVL 9

Expert Comment

by:McOz
ID: 35007608
Sorry about the delay --

To insert the VBA code as a macro:
1. press Alt+F11 to open Microsoft Visual Basic
2. click Insert > Module
3. paste the attached code into the window that appears. This code will give the user a "Save as" box, so they can choose where to save and what to name the new file.
4. Save, and close Visual Basic
5. now you can assign this macro to a keyboard shortcut or button to run it.

McOz
Sub SaveActiveSheet()
    ActiveSheet.Move
    fname = Application.GetSaveAsFilename("NewWorkbook", "Excel Files (*.xls), *.xls")
    If fname <> False Then ActiveWorkbook.SaveAs Filename:=fname, FileFormat:= _
        xlOpenXMLWorkbook, CreateBackup:=False
End Sub

Open in new window

0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

What is a Form List Box? (skip if you know this) The forms List Box is the alternative to the ActiveX list box. If you are using excel 2007, you first make sure you have a developer tab (click the Orb)->"Excel Options"->Popular->"Show Developer tab…
Sparklines have been introduced with Excel 2010 and are a useful tool for creating small in-cell charts, used for example in dashboards. Excel 2010 offers three different types of Sparklines: Line, Column and Win/Loss. What it does not offer is a…
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 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.

708 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now