VBA save problem with date

mcmdm50

New Member
Joined
Mar 25, 2012
Messages
14
Using Excel 2016, I am trying to create a "save as" button and pull data from 3 cells to save the file. The problem is that cell S2 contains a date (which I need in the file name) but I can't seem to get it to work. When I test it and replace the date with text, it works. Can anyone help. Below is the code.
Thank You,

Private Sub CommandButton1_Click()
Dim Path As String
Dim FileName1 As String
Dim FileName2 As String
Dim FileName3 As String
Path = "\\teradump\TitleAttorneySupport\Pending New Approvals\"
FileName1 = Range("S2")
FileName2 = Range("F3")
FileName3 = Range("I2")
ActiveWorkbook.SaveAs Filename:=Path & FileName1 & "-" & FileName2 & "-" & FileName3 & ".xlsm", FileFormat:=52 End Sub
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
How about
Code:
Path & format(FileName1,"dd-mm-yyyy") & "-" & FileName2 &
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,885
Members
452,364
Latest member
springate

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