Solved

Exporting individual Excel sheets to individual files

Posted on 2011-02-28
5
358 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

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…
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…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

831 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