writing a macro to save a workbook

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
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
 

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

Back
Top