Forum Discussion

AnaPistol's avatar
AnaPistol
Copper Contributor
Jun 18, 2019
Solved

Automatically name a new worksheet with a date sequence

Hello,   I am trying to create a workbook in which new worksheet names are automatically showing the current date and month. For example, i have a worksheet named May 2019. I would like to insert ...
  • JKPieterse's avatar
    JKPieterse
    Jun 27, 2019

    AnaPistol This macro checks if there alreay is a worksheet for the current month. If not it creates one. If there is, it selects it:

    Sub AddMonthSheet()
        Dim sName As String
        Dim oSh As Worksheet
        sName = Format(Date, "yyyy-mmm")
        On Error Resume Next
        Set oSh = Worksheets(sName)
        If oSh Is Nothing Then
            Set oSh = Worksheets.Add
        End If
        oSh.Name = sName
        oSh.Activate
    End Sub
    

Resources