Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Exporting individual Excel sheets to individual files

Posted on 2011-02-28
5
Medium Priority
?
366 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
[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
  • 2
  • 2
5 Comments
 
LVL 9

Accepted Solution

by:
McOz earned 1000 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
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 …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

715 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