writing a macro to save a workbook

B

Brian

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
 
O

OssieMac

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
 
D

Dave Peterson

Check your other post, too.
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
 
Top