Save file with today date

maheshgmv

New Member
Joined
Nov 11, 2015
Messages
4
Hi All,

I am new to excel Vba , Please help me with How to save the current excel file with today's date Minus one ? For example todays date is 11-11-12 i want to save file as 10-11-15 .


And also i run three reports daily lets say i run A,B,C. A&B reports will run before 12 in night and C report run after 12AM so i want C report to save with date-1 format and A,B reports with todays date
 
Last edited:

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Are you wanting to put code into each workbook or have a workbook with code that runs on other workbooks?

What do your existing filenames look like?

To partially answer your question ... I see you are using dd-mm-yy so here is some code to tell you that:

Code:
Sub StringYesterday()
   Dim sDate As String
   sDate = Format(Date - 1, "dd-mm-yy")
   MsgBox sDate
End Sub

Sub StringToday()
   Dim sDate As String
   sDate = Format(Date, "dd-mm-yy")
   MsgBox sDate
End Sub
 
Upvote 0
Are you wanting to put code into each workbook or have a workbook with code that runs on other workbooks?

What do your existing filenames look like?

To partially answer your question ... I see you are using dd-mm-yy so here is some code to tell you that:

Code:
Sub StringYesterday()
   Dim sDate As String
   sDate = Format(Date - 1, "dd-mm-yy")
   MsgBox sDate
End Sub

Sub StringToday()
   Dim sDate As String
   sDate = Format(Date, "dd-mm-yy")
   MsgBox sDate
End Sub


Hi
Thanks for your reply

Basically I have one workbook that contains code which generates three reports . .

1 report is Russia sales report and second is German 3 is us sales report

When i run russia sales report which saves with today date but how to put a condition for us to save with today-1 using if condition ???
 
Upvote 0
Hi
Thanks for your reply

Basically I have one workbook that contains code which generates three reports . .

1 report is Russia sales report and second is German 3 is us sales report

When i run russia sales report it saves with today date but how to put a condition for us to save with today-1 using if condition ???
 
Upvote 0
What do your existing filenames look like?

Are you saving the whole workbook 3 times? What is the difference?
 
Upvote 0

Forum statistics

Threads
1,214,587
Messages
6,120,406
Members
448,958
Latest member
Hat4Life

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