View Single Post
 
Old 04-20-2021, 10:04 AM
ChrisOK ChrisOK is offline Windows 10 Office 2019
Advanced Beginner
 
Join Date: Sep 2016
Posts: 54
ChrisOK is on a distinguished road
Question Convert NowMonth MonthNow to double digits mm

How do I convert / format the month name of a SHEET / TAB to be double digits rather than single?
It currently produces: "2021-3" but need "2021-03"

Code:
Sub InsertNewWorksheetAndName()

    nowMonth = Month(Now) - 1
    nowYear = Year(Now)

    ActiveWorkbook.Sheets.Add After:=Worksheets(Worksheets.Count)
    ActiveWorkbook.Sheets(Worksheets.Count).Name = nowYear & "-" & nowMonth

End Sub
Reply With Quote