Export just one sheet from a workbook

G

Grek

Hi again,

In my excell project, there are 3 sheets in my workbook :

Results
Sheet2
Sheet3

I would like to save only the results' sheet.

At the moment I create a new workbook then I copy/Paste Special Value
the results into it,... but I'm sure there is an easier way to do that
It shoulf be possible to export only the sheet that I want, withou
creating a new workbook, right ?

Here is my code. Could you tell me if it's possible to make it easie
?

Thank you very much in advance,

Greg


Range("G1").Select
Selection.Copy
Range("H1").Select
Selection.PasteSpecial Paste:=xlValues
Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False

Range("H1").Select
Today = Range("H1").Value


Workbooks.Add
ActiveWorkbook.SaveAs Filename:="c:\myfile" & Today
".xls"
Windows("MyBook.xls").Activate

Sheets("Results").Select
Application.CutCopyMode = False
Sheets("Results").Copy Before:=Workbooks("myfile"
Today & ".xls").Sheets(1)
Sheets("Results").Select
Cells.Copy
Cells.PasteSpecial xlPasteValues

Application.DisplayAlerts = False
Sheets("Sheet1").Select
Application.DisplayAlerts = False
Sheets("Sheet2").Select
ActiveWindow.SelectedSheets.Delete
Sheets("Sheet3").Select
ActiveWindow.SelectedSheets.Delete
Application.DisplayAlerts = True

ActiveWorkbook.Save


ActiveWindow.Clos
 
D

Dave Peterson

You don't have to create the new workbook first.

Record a macro when you rightclick on the Results tab and move or copy (choose
move) to a new workbook.

Then copy|paste special|values and save from there:

Option Explicit
Sub Macro1()
Sheets("Results").Copy
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
End Sub

Was the code the macro recorder came up with (w/o the save).

(I did convert all the formulas to values. And I don't need to delete any of
those sheets that are in the new workbook.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top