Auto generate "Save As" filename from text

Excelo

New Member
Joined
Apr 7, 2011
Messages
17
Hi All,

I'm trying to have "save as" file name automatically generate, Excel 2007, from data in two cells, client name and current date. I've seen, but it doesn't seem to work.

Sub SaveMe()
ThisWorkbook.SaveAs FileName:=Range("C1").Value
End Sub

I'm not too technical, but I can follow instructions pretty well. Any help is greatly appreciated. Also, if you know how to do it for Word 2007 it would also be appreciated, even more so.

Thanks
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
With client in C1 and date in D1 try like this

Code:
Sub SaveMe()
ThisWorkbook.SaveAs Filename:=Range("C1").Value & Format(Range("D1").Value, "dd-mm-yyyy") & ".xlsm"
End Sub
 
Upvote 0
Thank you!

Is there a way to change where it is saved to? By default it saves to My Documents. I want it to save to a folder I've created
 
Upvote 0
Try this - change the part in red to the correct path

Sub SaveMe()
ThisWorkbook.SaveAs Filename:="C:\Test\" & Range("C1").Value & Format(Range("D1").Value, "dd=mm-yyyy") & ".xls"
End Sub
 
Upvote 0
Thanks for the code! How would you add this to an active X CommandButton code? Basically if I want a user to save a workbook with certain data from multiple cells how do I make it easy for them to click a button? Thanks.
 
Upvote 0

Forum statistics

Threads
1,224,574
Messages
6,179,633
Members
452,933
Latest member
patv

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top