How to save a worksheet in a project as a SEPARATE FILE

V

vbnewbie

I have, as part of a project, a print form I want to save as a separate file
without losing focus on the original. Can anyone help?
 
M

meh2030

I have, as part of a project, a print form I want to save as a separate file
without losing focus on the original. Can anyone help?

I'm not exactly sure how you want the data to be copied, but there is
sample code below of how to copy the active sheet to a new workbook
and open the save as dialog box to save the newly created workbook.

Best,

Matthew Herbert

Sub SaveWorksheet()
Dim Wks As Worksheet
Dim wksCopy As Worksheet
Dim Wkb As Workbook
Dim strFileName As String

Set Wks = ActiveSheet
Set Wkb = Workbooks.Add

'copy the worksheet to a new workbook
Wks.Copy After:=Wkb.Sheets(Wkb.Sheets.Count)

'save the file
strFileName = Application.GetSaveAsFilename()
If strFileName Then
Wkb.SaveAs strFileName
End If

End Sub
 
P

Peter T

What's a "print form" ?

To do what your subject line implies, simply

ActiveSheet.Copy

This will create a new file, save it as required, and close it.

Regards,
Peter T
 

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