Macro Save file name derived from cells

SaiChu

New Member
Joined
Feb 20, 2012
Messages
17
Hi Mr. Excel,

Below is a fantastic macro you shared with us to save the file name derived from a cell. Is it possible to save a file name derived from 3 cells, i.e. Cells A1, C5, D8?

Sub SaveAsA1()
ThisFile = Range("A1").Value
ActiveWorkbook.SaveAs Filename:=ThisFile
End Sub

Thank you,
Sai Chu
 

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,)
Hi SaiChu,

Sure it is - the filename is just a string - just don't have any illegal characters.
 
Upvote 0
Try

Code:
Sub SaveAsA1()
ThisFile = Range("A1").Value & Range("C5").Value & Range("D8").Value
ActiveWorkbook.SaveAs Filename:=ThisFile
End Sub
 
Upvote 0
Hi MrExcel MVP,

Thank you for your quick reply.
It is giving me a 400 error. Is it because my cell D8 is a date?

Thank you,
Sai Chu
 
Upvote 0
Maybe this

Code:
Sub SaveAsA1()
ThisFile = Range("A1").Value & Range("C5").Value & Format(Range("D8").Value, "mm-dd-yyyy") & ".xls"
ActiveWorkbook.SaveAs Filename:=ThisFile
End Sub
 
Upvote 0
What exactly is in those cells and which version of Excel are you using?
 
Upvote 0
Oh Sorry my mistake. I had an extra space in the date format. It is working like a dream now.
THANK YOU SO, SO, SO MUCH!!!!!!
 
Upvote 0
Hi Mr. Excel,

Below is a fantastic macro you shared with us to save the file name derived from a cell. Is it possible to save a file name derived from 3 cells, i.e. Cells A1, C5, D8?

Sub SaveAsA1()
ThisFile = Range("A1").Value
ActiveWorkbook.SaveAs Filename:=ThisFile
End Sub

Thank you,
Sai Chu


This is great - I would like use this for generating quotes in specific location:
- it goes to a server folder,
- then into sub folder 1,
- then sub folder 2,
- finally a folder with the quote ref (part of save as file name), which has already been created

Can this be done as part of the above macro?
thanks in advance
 
Upvote 0
Similar to the post above. Is there a command / sub i can add to this to define the file path i want to save it to?

Setting up a template for various people and want them to hit the normal save button to save to the normal file path (as usual) but i also plan on using this subroutine and attaching it to a clickable button on the sheet which saves a backup to a different filepath folder.
 
Upvote 0

Forum statistics

Threads
1,203,078
Messages
6,053,402
Members
444,661
Latest member
liamoohay

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