date and day question

ajm

Well-known Member
Joined
Feb 5, 2003
Messages
1,971
Office Version
  1. 365
Platform
  1. Windows
I had something like this very recently but can't find it anywhere. I am adding a command button to create a new workbook. this new workbook needs a date extension on the end of the standard name. I want this date extension to be the Thursday of the current week. That is, press the button on tuesday 17 June or Wednesday 18 June and the file created will be named "File 19062008.xls".

cheers

ajm
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Simon Lloyd

Well-known Member
Joined
Sep 10, 2006
Messages
756
I have provided code for weekdays only but you get the idea for extending it!
Code:
Sub datez()
Dim MyDate As Date
Select Case Format(Date, "ddd")
Case Is = "Mon"
MyDate = Date + 3
Case Is = "Tue"
MyDate = Date + 2
Case Is = "Wed"
MyDate = Date + 1
Case Is = "Thu"
MyDate = Date
Case Is = "Fri"
MyDate = Date - 1
End Select
ThisWorkbook.SaveAs (ThisWorkbook.Name & " " & Format(MyDate, "ddmmyyyy"))
End Sub
 
Upvote 0

ajm

Well-known Member
Joined
Feb 5, 2003
Messages
1,971
Office Version
  1. 365
Platform
  1. Windows
Thanks Simon. Not waht I originally had but does the trick perfectly. Many thanks.
 
Upvote 0

Forum statistics

Threads
1,195,920
Messages
6,012,310
Members
441,690
Latest member
CyberWrek

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
Top