Date for excel workbook

aacod

Well-known Member
Joined
Mar 20, 2009
Messages
667
I have an excel workbook with 31 sheets for the month og March, each representing a day in a month. I would like an excel formula which would put the date automatically on each sheet for that particular day, e.g. 1 March, 09 on sheet 1 and 2 March on sheet 2 etc. for the whole month. Thanks
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
This has almost no protection against crashes or errors - i.e., if we run out of sheets or something.

Code:
Sub foo()
Dim ws As Worksheet
Dim myDate As Date

Set ws = ActiveSheet
myDate = DateSerial(2009, 3, 1)

On Error Resume Next
x = 1
Do While myDate <= DateSerial(2009, 3, 31) AND x <= 31
    ws.Name = Format(myDate, "mmmm d, yyyy")
    myDate = myDate + 1
    Set ws = ws.Next
    x = x + 1
Loop

End Sub


(Names tabs with days of month in march)


Alex
 
Upvote 0
This works fine , but would appreciate if it works in the following format 1 Mar, 2 Mar, 3 Mar etc .

Thanks
 
Upvote 0
Sheet Names are 1 Mar, 2 Mar till 31 Mar for the whole month of March.
 
Upvote 0
Ahh, mis-understood the question I thought you wanted the day of the current month based on sheet position to be displayed in cell.
 
Upvote 0

Forum statistics

Threads
1,214,870
Messages
6,122,019
Members
449,060
Latest member
LinusJE

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