Solved

Exporting individual Excel sheets to individual files

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

948 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

21 Experts available now in Live!

Get 1:1 Help Now