date and day question

ajm

Well-known Member
Joined
Feb 5, 2003
Messages
2,005
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

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
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
Thanks Simon. Not waht I originally had but does the trick perfectly. Many thanks.
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,695
Members
448,979
Latest member
DET4492

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