Vba to save as filename = certain characters of cells than format those characters

baker_89

New Member
Joined
Aug 25, 2014
Messages
42
I have some code that updates a bunch of data from another sheet now I want to add in to automatically SaveAs and have the file name automatically added from a cell. I have most of it working except the characters I am copying are formatted MM/DD/YY and the "/" cannot be a part of the file name. So I need to format it to "MM-DD-YY DDD" I've tried a few different ways but it keeps getting errors.

This is what I have for that part of the code.

Dim FileName As String
Dim fileSaveName As Variant

FileName = "Sheet" & range("A1").Characters(start:=22, Length:=9).Text (format here?)
fileSaveName = Application.GetSaveAsFilename(InitialFileName:=FileName , _
fileFilter:="Excel Files (*.xlsm), *.xlsm")
InitialFilePath = "C:\Temp\"


Comes up as "Sheet 05/16/15".

I want it to read "Sheet 05-16-15 (Sat)"
 
Last edited:

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Code:
FileName = "Sheet " & Format(Range("A1").Characters(start:=22, Length:=9).Text, "mm-dd-yyyy (dd)")
 
Last edited:
Upvote 0
Code:
FileName = "Sheet " & Format(Range("A1").Characters(start:=22, Length:=9).Text, "mm-dd-yyyy (dd)")


Worked Perfect!

Also is there a way to get the cell values to update before the SaveAs Dialog comes up? Currently the code runs and the SaveAs dialog shows than the values do no update until after the Save is complete. I would like them to show before the user saves so they can double check things are correct.
 
Upvote 0
Worked Perfect!

Also is there a way to get the cell values to update before the SaveAs Dialog comes up? Currently the code runs and the SaveAs dialog shows than the values do no update until after the Save is complete. I would like them to show before the user saves so they can double check things are correct.

Woops! Answered my own question, just had to change to True - "Application.ScreenUpdating = False"
 
Upvote 0

Forum statistics

Threads
1,215,358
Messages
6,124,487
Members
449,165
Latest member
ChipDude83

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