Save as with calculated filename - VBA

Vispon

New Member
Joined
Jul 12, 2010
Messages
20
Hi everyone, I've found a few different threads on the elements of this but I haven't been able to cobble them together, hoping you may be able to help.

I'm looking to run a command which will
  • open the save as dialogue on screen
  • Defaultly fill the file name with 'INV_TRC_[cel c1]_[current date time as DDMMYYYYHHMMSS]
  • file type CSV

I came across the below which does some of it but I'm having trouble piecing it all together :/

Code:
[COLOR=#2D4050][FONT='inherit']Sub SaveUnique() 
'
' Save a file with a unique name 
' 
ActiveWorkbook.SaveAs Filename:="C:\Temp\Book" & Format(Now(), "yyyymmddhhmmss") & ".xlsx", _ 
FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False 
End Sub[/FONT][/COLOR]
 
Last edited:

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Does this do what you want?

Code:
Sub savecsv()
myfilename = "INV_TRC_" & Range("c1") & "_" & Format(Now(), "DDMMYYYYHHMMSS")
Filename = Application.GetSaveAsFilename(InitialFileName:=myfilename, fileFilter:="csv Files (*.csv), *.csv")

End Sub
 
Upvote 0
Thanks Scott

That brings up the save dialogue with the file name perfectly.
The only odd issue I'm having is when I then click save the file doesn't seem to actually be saved in the destination?
 
Upvote 0
Try this.


Code:
Sub savedi()
myfilename = "INV_TRC_" & Range("c1") & "_" & Format(Now(), "DDMMYYYYHHMMSS")
Filename = Application.GetSaveAsFilename(InitialFileName:=myfilename, fileFilter:="csv Files (*.csv), *.csv")
ActiveWorkbook.SaveAs Filename:=Filename

End Sub
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

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