Solved

Exporting individual Excel sheets to individual files

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

751 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