Save single worksheet?

M

Mat

I've got a workbook containing multiple sheets, one of
which is a Invoice. I want the user to be able to press a
button, and for it to save the Invoice sheet only. I hit
the problem on the saving part. I can get it to save the
whole workbook, but not the single sheet.

How could I do this in VBA?
Thanks,
Mat,
(e-mail address removed)
 
R

Ron de Bruin

Try this Mat

Sub test()
Sheets("Invoice").Copy
ActiveWorkbook.SaveAs "c:\data\Invoice " & Format(Now, "dd-mm-yy h-mm-ss")
ActiveWorkbook.Close
End Sub
 
B

Bob Phillips

Mat,

You can only save a workbook, so you would need to move the worksheet to a
new workbook and then save that, something like

Worksheets("Sheet1").Copy
ActiveWorkbook.SaveAs Filename:= "myfile.xls"


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 

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