VB Script/VBA for date


Hi Subbu,

Thanks for helping me. I have a excel workbook whereby i need to "save as"the workbook with 2 dates on it but im not sure how to do it. right now i can get today's date from "Now" but i want my workbook to be saved in this name.

GPT & DDV Website Report - (25-07-2016 to 31-07-2016)

"31-07-2016" - this date will be today's date and "25-07-2016" is 6 days minus the today's date.i have written a code as seen below but im not sure how to incorporate 2 dates

Sub Saving_Workbook()

   ThisWorkbook.SaveAs ThisWorkbook.Path & "\" & "GPT & DDV Website Report - (" & ((Format(Now, "dd-mm-yyyy")) & ")")
End Sub

Thanks for helping me again.

Hi Sudha,

Sorry for delay.  I used DateAdd method and passed -6 days to achieve your objective.
You can try below code and it should work as you expected.


MsgBox "GPT & DDV Website Report - (" & Format(DateAdd("d", -6, Format(Now)), "dd-mm-yyyy") & " to " & ((Format(Now, "dd-mm-yyyy")) & ")")


after your testing you paste below code for filename.

ThisWorkbook.SaveAs ThisWorkbook.Path & "\" & "GPT & DDV Website Report - (" & Format(DateAdd("d", -6, Format(Now)), "dd-mm-yyyy") & " to " & ((Format(Now, "dd-mm-yyyy")) & ")")

Please feel free to contact me for any questions.


VB Script

All Answers

Answers by Expert:

Ask Experts




I can answer VB Script questions which are related to Visual Basic / VBA / QTP Scripts.


8 Years

Master of Computer Applications

Awards and Honors
Established Member from QA Forums and Brainbench certification

©2016 About.com. All rights reserved.