View Single Post
 
Old 04-20-2021, 03:37 PM
macropod's Avatar
macropod macropod is offline Windows 10 Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Code:
Sub InsertNewWorksheetAndName()
Application.ScreenUpdating = False
Dim nowMonth As Long, nowYear As Long
nowMonth = Month(Now) - 1: nowYear = Year(Now)
With ActiveWorkbook
  .Sheets.Add After:=Worksheets(.Worksheets.Count)
  .Sheets(.Worksheets.Count).Name = nowYear & "-" & Format(nowMonth, "00")
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote