ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   writing a macro to save a workbook (https://www.excelbanter.com/excel-worksheet-functions/166685-writing-macro-save-workbook.html)

Brian

writing a macro to save a workbook
 
I have a workbook with a macro that save the workbook, however i want the
macro to save it as the same file name as data that was entered into a
certain cell or cells pural if able to

OssieMac

writing a macro to save a workbook
 
Hi Brian,

Something like this:-

Sub Create_File_Save()
Dim strPath As String
Dim strMyFileName As String

strPath = CurDir & "\" 'Ensure backslash on end of path

'Code uses Current Directory as path.
'Can create path as follows:-
'strPath = "C:\Documents\MyName\"


With Sheets("Sheet1")
'Insert more ambersands and ranges if required
strMyFileName = .Range("A1") & .Range("B1") & ".xls"

'If spaces required in filename the use this option
'strMyFileName = .Range("A1") & " " & .Range("B1") & ".xls"
End With


strMyFileName = strPath & strMyFileName

ActiveWorkbook.SaveAs Filename:=strMyFileName

End Sub

--
Regards,

OssieMac


"Brian" wrote:

I have a workbook with a macro that save the workbook, however i want the
macro to save it as the same file name as data that was entered into a
certain cell or cells pural if able to


Dave Peterson

writing a macro to save a workbook
 
Check your other post, too.

Brian wrote:

I have a workbook with a macro that save the workbook, however i want the
macro to save it as the same file name as data that was entered into a
certain cell or cells pural if able to


--

Dave Peterson


All times are GMT +1. The time now is 05:35 PM.

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