ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I save a single worksheet to a different file using VBA 03 (https://www.excelbanter.com/excel-programming/419137-how-do-i-save-single-worksheet-different-file-using-vba-03-a.html)

Alpineskier

How do I save a single worksheet to a different file using VBA 03
 
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,"",F ALSE,"",TRUE). I am using
Excel 2003 and VBA v6.5.


JMay

How do I save a single worksheet to a different file using VBA 03
 
Here's a start...

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

"Alpineskier" wrote:

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,"",F ALSE,"",TRUE). I am using
Excel 2003 and VBA v6.5.


joel

How do I save a single worksheet to a different file using VBA
 
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

"Alpineskier" wrote:

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,"",F ALSE,"",TRUE). I am using
Excel 2003 and VBA v6.5.


"JMay" wrote:

Here's a start...

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

"Alpineskier" wrote:

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,"",F ALSE,"",TRUE). I am using
Excel 2003 and VBA v6.5.



All times are GMT +1. The time now is 05:13 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com