How do I save a single worksheet to a different file using VBA 03

A

Alpineskier

I am converting an old Excel 4 macro to VBA and I want to save single
worksheet to a new .xls file. The old command was
=SAVE.AS(path&CELL("contents",Invoice!$H$2),1,"",FALSE,"",TRUE). I am using
Excel 2003 and VBA v6.5.
 
J

JMay

Here's a start...

Sub Macro1()
fName = Sheets("Invoice").Range("$H$2").Value
Set NewBook = Workbooks.Add
NewBook.SaveAs Filename:=fName
End Sub
 
J

Joel

the new workbook in JMay code will create an empty workbook. the code below
will save the current workbook to a new filename.

Sub Macro1()
Folder = activeworkbook.path
fName = Sheets("Invoice").Range("$H$2").Value
Thisworkbook.SaveAs Filename:=Folder & "\" & fName
End Sub
 

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