Hello,

I have VBA macro which copies first sheet and creates new sheets for months in a year. Days in a month from 1st sheet are copied in a range of E2:AI2, that's 31 days. When new sheet for new month is created, I want this range of days to be exact as days according to the month, not always 31 days.

Problem is that after range of days there are still columns in range AJ:AN, so
EntireColumn.delete
is not a proper solution.

Can this be done with VBA, or will I must delete every redundant columns on sheets manually ?

Here is code:

Sub DoMonths()
    Dim j As Integer
    Dim k As Integer
    Dim sMo(12) As String
    
    sMo(1) = "Januar"
    sMo(2) = "Februar"
    sMo(3) = "Marec"
    sMo(4) = "April"
    sMo(5) = "Maj"
    sMo(6) = "Junij"
    sMo(7) = "Julij"
    sMo(8) = "Avgust"
    sMo(9) = "September"
    sMo(10) = "Oktober"
    sMo(11) = "November"
    sMo(12) = "December"
        
    Application.ScreenUpdating = False
    For j = 1 To 12
      Sheets(1).Copy after:=Sheets(Sheets.Count)
          With ActiveSheet
          .Name = sMo(j) & " " & .Range("A1").Value
        For k = 1 To Day(DateSerial(.Range("A1").Value, j + 1, 0))
          .Cells(2, 4 + k).Value = DateSerial(.Range("A1").Value, j, k)
        Next k
      End With
    Next j
    Application.ScreenUpdating = True
    Sheets(1).Activate
    
    Application.DisplayAlerts = False
    Sheets(1).Delete
    Application.DisplayAlerts = True

    End Sub