Help Needed: VBA code to copy a worksheet into a new workbook

  • Thread starter Thread starter Kenwalt
  • Start date Start date
K

Kenwalt

Hi All,

I am trying to write VBA code that accomplishes the following:

1) Copy Sheet1 from workbook1 into a new workbook.

2) Open the "Save as" dialog box that allows the user to name and save
the new workbook.

3)Return the user to workbook1.

My problem is I don't know how to open the "Save as" dialog box.

Thanks in advance
Bob
 
Dim sFile
Workbooke("myFile.xls").Worksheets("Sheet1").Copy
sFile = Application _
.GetOpenFilename("Microsoft Excel Files (*.xls), *.xls")
If sFile <> False Then
ActiveWorkbook.SaveAs Filename:=sFile
End If
End If

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
Thanks for your help. I probably should have mentioned that I am trying
to execute this procedure using a command button within a UserForm.

I am able to save the exported worksheet using your code but when I try
to interact with the open UserForm I get an error.

Any idea?

Thanks again.
 
Back
Top