Save file using cell contents as file name
In this blog, I'll explain how to save the file with cell content as file name.
Assumption:
The Cell Value which is used for file name is A1 and the extension is ".xlsx".
Steps:
1. Open a new file
2. Press Alt+F11 to open VBA editor
3. In the left navigation window select ThisWorkbook
4. In the editor window enter the code below
5. Close the VBA editor
6. Save the file as Macro Enabled File
7. Test with you inputs
Code:
Sub FileNameAsCellContent()
Dim FileName As String
Dim Path As String
Application.DisplayAlerts = False
Path = "C:\" 'Change the directory path here where you want to save the file
FileName = Range("A1").Value & ".xlsx" 'Change extension here
ActiveWorkbook.SaveAs Path & FileName, xlOpenXMLWorkbook 'Change the format here which matches with the extention above. Choose from the following link http://msdn.microsoft.com/en-us/library/office/ff198017.aspx
Application.DisplayAlerts = True
ActiveWorkbook.Close
End Sub
I think this has been informative and I thank you for viewing.
-Saurabh
Attachment | Size |
---|---|
FileNameAsCellContent.xlsm | 11.91 KB |
- saurabhlakhanpal's blog
- Login or register to post comments
- 116813 reads
Brilliant
Thanks, this works perfectly.
Can you make it so it will save to a folder name specified in Cell A1 in C:\My folder\
eg. Cell A1 says "John Smith" so it will save to C:\My folder\John Smith\
Any help would be much appreciated.
thanks
Reply is getting blocked. Contact me on my email.
Thanks
Cant post anything. Worst spam filter ever
What is your email?
What is your email?