Add Month to New Sheet

MasterChief

Board Regular
Joined
Feb 14, 2006
Messages
172
I use the following code to add a new sheet to my workbook which works great,

Sub AddNameNewSheet2()

'Remember where we started
'Not needed if you don't want to return to where you started but want
'to stay on the New Sheet
Dim CurrentSheetName As String
CurrentSheetName = ActiveSheet.Name

'Add New Sheet
Sheets.Add

'Make sure the name is valid
On Error Resume Next

'Get the new name
ActiveSheet.Name = InputBox("Name for new worksheet?")

'Keep asking for name if name is invalid
Do Until Err.Number = 0
Err.Clear
ActiveSheet.Name = InputBox("Try Again!" _
& vbCrLf & "Invalid Name or Name Already Exists" _
& vbCrLf & "Please name the New Sheet")
Loop
On Error GoTo 0

'Go back to where you started
'Not needed if you don't want to return to where you started but want
'to stay on the New Sheet
Sheets(CurrentSheetName).Select

End Sub



what i want to do is add this to the code to fill in the currant month in cell C3, but I`m not sure where to place it.

=TEXT(TODAY(),"MMMM")

Any help would be greatfull.
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Not sure I understand your question about where to put the code. Why not put it at the end of your code?
 
Upvote 0
try this:
Code:
Range("C3").FormulaR1C1 = "=TEXT(TODAY(),""MMMM"")"

btw when not sure how to do something with VBA try the Macro Recorder
 
Upvote 0

Forum statistics

Threads
1,224,269
Messages
6,177,563
Members
452,784
Latest member
talippo

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