Save As under specific File Name

trjhart

New Member
Joined
Jun 20, 2022
Messages
2
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Hi All,

I'm trying to create a copy of a file and then save it by using certain text/values within a workbook. The first value is text and the second value is the date but it needs to be in the format "yymmdd". The file should be written as so "SXB220620"

Can anyone help?

VBA Code:
Sub Save_excel_file()

ActiveWorkbook.SaveAs Filename:=ThisWorkbook.Sheets("Front Sheet").Range("K1").Value & Format(Cells(1, 12), "yymmdd")

End Sub
 

Attachments

  • Excel Cells.PNG
    Excel Cells.PNG
    2 KB · Views: 9

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
NVM think I solved it with this

VBA Code:
Sub Save_excel_file()
'save as with the filename prefilled by value of K1
        Application.Dialogs(xlDialogSaveAs).Show Sheet1.Range("K1") & Format(Cells(1, 12), "yymmdd")
End Sub
 
Upvote 0
Solution
I have a similar problem. I have a file that needs to be saved with the name prefilled in cell J2.
I tried the code above, but without the "& Format etc". It doesn't work for me.
 
Upvote 0

Forum statistics

Threads
1,215,836
Messages
6,127,177
Members
449,368
Latest member
JayHo

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