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:

strive4peace

Well-known Member
Joined
Jul 6, 2009
Messages
678
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
 

maheshgmv

New Member
Joined
Nov 11, 2015
Messages
4
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 ???
 

maheshgmv

New Member
Joined
Nov 11, 2015
Messages
4
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 ???
 

strive4peace

Well-known Member
Joined
Jul 6, 2009
Messages
678
What do your existing filenames look like?

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

Forum statistics

Threads
1,081,972
Messages
5,362,502
Members
400,677
Latest member
champchamp

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top