![]() |
Saving with Macro
Hi Is it possible to use a macro to retrieve a value within a specific cell and save the workbook using that value for the file name? For example if the cell A1 had the value details, then the macro would save the workbook as details.xls Thank you in advance for any help !! -- mabbutt ------------------------------------------------------------------------ mabbutt's Profile: http://www.excelforum.com/member.php...o&userid=34294 View this thread: http://www.excelforum.com/showthread...hreadid=541058 |
Saving with Macro
Here's some code you can use to get going: you may need to alter it to
have it perform to your specs. You can specify a folder location with the NewPath variable; when you run this, the file is saved using the value of cell A1 as filename. Let us know if we can provide additional help: Sub SaveAs() Dim NewPath As String Dim NewFileName As String NewPath = "c:\" NewFileName = Range("a1").Value ActiveWorkbook.SaveAs Filename:=NewPath & NewFileName, _ FileFormat:=xlNormal, Password:="", WriteResPassword:="", _ ReadOnlyRecommended:=False, CreateBackup:=False End Sub |
Saving with Macro
Hi Thank you for the fast reply. I have found out another way to do this which is this: Sub SaveName() ActiveSheet.Range("B4").Select FileName = "H:\E5\Test\" & ActiveCell & ".xls" ActiveWorkbook.SaveAs FileName:=FileName End Sub I prefer your way though as it looks a little bit more structured. Thank you so much for your help !!!! -- mabbutt ------------------------------------------------------------------------ mabbutt's Profile: http://www.excelforum.com/member.php...o&userid=34294 View this thread: http://www.excelforum.com/showthread...hreadid=541058 |
All times are GMT +1. The time now is 05:28 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com