Saving Worksheets

G

Guest

I have a vba application I'm working on that creates numerous worksheets
within a workbook. I need to save off a copy of specific worksheets from the
workbook to their own file name. The object model appears to support that by
using the saveas method with a worksheet object rather than the workbook
object. When I try to actually do that in code, though, it saves the entire
workbook. My work around is to save it then delete all of the worksheets I
don't want, but that seems to be an around the elbow way to get the job done.
Is there a way to save a worksheet out of a workbook?

Thanks,
Mike
 
G

Guest

Try this:
Sub test()
Sheets("YourSheetName").Select
Sheets("YourSheetName").Copy
ActiveWorkbook.SaveAs Filename:= _
"Yourpath" & "YourSheetName", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
End Sub

Regards,
Stefi


„Mike†ezt írta:
 
G

Guest

Thanks Stefi...that worked very well!

Stefi said:
Try this:
Sub test()
Sheets("YourSheetName").Select
Sheets("YourSheetName").Copy
ActiveWorkbook.SaveAs Filename:= _
"Yourpath" & "YourSheetName", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
End Sub

Regards,
Stefi


„Mike†ezt írta:
 

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