VBA code to name the worksheet with quarter end date automatically
Hello everyone
i am new to VBA codings.. can anyone please help?? i have been trying to figure this out on my own for the last two days and it's not going anywhere. Can anyone correct my codes or suggest better codes for this?
I am trying to figure out codes to duplicate an existing worksheet with the worksheet name " XYZ report Q2 2016" and i want this sheet to be updated for Q3 with the worksheet name "XYZ report Q3 2016"
Below codes are what i have done so far and they are not working.
1. Sheet(2) Cell C4 has the last quarter date 30 June 2016
2. Sheet(1) is the report that i want to duplicate and that i wanted it to be updated for Q3
Sub Duplicatereport()
'
' Duplicatereport Macro
'
Dim mydate As Date
Dim mydate2 As Date
mydate = Sheets(2).Range("c4")
mydate2 = DateSerial(Year(mydate), Month(mydate) + 3, Day(mydate))
Sheets("XYZ Q2 2016").Copy after:=Sheets(2)
ActiveSheet.Name = Format(mydate2, "mm yyyy")
End Sub
Bookmarks