In the code below, Page activation doe not appear to be calling 'DueDate' : Option Explicit
Private Sub Worksheet_Activate()
Me.Unprotect Password:="edit" ' Unlock the sheet
Application.EnableEvents = False
Dim currentMonth As String
Dim currentMonthColumn As Integer
Dim taskRow As Integer
' Get the current date and month
currentMonth = Format(Date, "mmm")
' Find the column representing the current month
For currentMonthColumn = 2 To 13
If Cells(1, currentMonthColumn).Value = currentMonth Then Exit For
Next
' Update current month in Z1 as mmm
Cells(1, 27).Value = currentMonth
' Loop through each row in the task range
For taskRow = 2 To 13
' Check if the current month's cell is empty (no date entered)
If IsEmpty(Cells(taskRow, currentMonthColumn)) Then
Cells(taskRow, 27).Value = "Task Not Completed: " & Cells(taskRow, 1).Value
Else
Cells(taskRow, 27).Value = "" ' Clear the status if a date is entered
End If
Next taskRow
Dim currentMonthz As String
Dim currentMonthColumnz As Integer
Dim taskRowz As Integer
' Get the current month as a three-letter abbreviation
currentMonthz = Format(Date, "mmm")
' Find the column representing the current month
For currentMonthColumnz = 14 To 25 ' Adjust range for columns N to Y
If Cells(1, currentMonthColumnz).Value = currentMonthz Then Exit For
Next
' Copy only values from the current month's data to column Z
Range(Cells(1, currentMonthColumnz), Cells(14, currentMonthColumnz)).Copy
Cells(1, 26).PasteSpecial xlPasteValues ' Adjust destination column as needed
Application.CutCopyMode = False ' Clear clipboard
Application.EnableEvents = True
Me.Protect Password:="edit" ' Lock the sheet
activeSheet.Calculate
Call DueDate
End Sub
Private Sub DueDate()
Me.Unprotect Password:="edit" ' Unlock the sheet
Application.EnableEvents = False
Dim currentMonth As String
currentMonth = Format(Date, "mmm")
Select Case currentMonth
Case 1:
If currentMonth = "Jan" And Range("AE1") <> "Jan" Then
Range("M2:M13").Copy
Range("AE2").PasteSpecial xlPasteValues
Range("C2:L13").ClearContents
Range("AE1") = "Jan"
End If
Case 2:
If currentMonth = "Feb" And Range("AE1") <> "Feb" Then
Range("B2:B13").Copy
Range("AE2").PasteSpecial xlPasteValues
Range("D2:M13").ClearContents
Range("AE1") = "Feb"
End If
Case 3:
If currentMonth = "Mar" And Range("AE1") <> "Mar" Then
Range("C2:C13").Copy
Range("AE2").PasteSpecial xlPasteValues
Range("E2:M13").ClearContents
Range("B2:B13").ClearContents
Range("AE1") = "Mar"
End If
Case 4:
If currentMonth = "Apr" And Range("AE1") <> "Apr" Then
Range("D2:D13").Copy
Range("AE2").PasteSpecial xlPasteValues
Range("F2:M13").ClearContents
Range("B2:C13").ClearContents
Range("AE1") = "Apr"
End If
Case 5:
If currentMonth = "May" And Range("AE1") <> "May" Then
Range("E2:E13").Copy
Range("AE2").PasteSpecial xlPasteValues
Range("G2:M13").ClearContents
Range("B2:D13").ClearContents
Range("AE1") = "May"
End If
Case 6:
If currentMonth = "Jun" And Range("AE1") <> "Jun" Then
Range("F2:F13").Copy
Range("AE2").PasteSpecial xlPasteValues
Range("H2:M13").ClearContents
Range("B2:E13").ClearContents
Range("AE1") = "Jun"
End If
Case 7:
If currentMonth = "Jul" And Range("AE1") <> "Jul" Then
Range("G2:G13").Copy
Range("AE2").PasteSpecial xlPasteValues
Range("I2:M13").ClearContents
Range("B2:F13").ClearContents
Range("AE1") = "Jul"
End If
Case 8:
If currentMonth = "Aug" And Range("AE1") <> "Aug" Then
Range("H2:H13").Copy
Range("AE2").PasteSpecial xlPasteValues
Range("J2:M13").ClearContents
Range("B2:G13").ClearContents
Range("AE1") = "Aug"
End If
Case 9:
If currentMonth = "Sep" And Range("AE1") <> "Sep" Then
Range("I2:I13").Copy
Range("AE2").PasteSpecial xlPasteValues
Range("K2:M13").ClearContents
Range("B2:H13").ClearContents
Range("AE1") = "Sep"
End If
Case 10:
If currentMonth = "Oct" And Range("AE1") <> "Oct" Then
Range("J2:J13").Copy
Range("AE2").PasteSpecial xlPasteValues
Range("L2:M13").ClearContents
Range("B2:I13").ClearContents
Range("AE1") = "Oct"
End If
Case 11:
If currentMonth = "Nov" And Range("AE1") <> "Nov" Then
Range("K2:K13").Copy
Range("AE2").PasteSpecial xlPasteValues
Range("M2:M13").ClearContents
Range("B2:J13").ClearContents
Range("AE1") = "Nov"
End If
Case 12:
If currentMonth = "Dec" And Range("AE1") <> "Dec" Then
Range("L2:L13").Copy
Range("AE2").PasteSpecial xlPasteValues
Range("B2:K13").ClearContents
Range("AE1") = "Dec"
End If
End Select
Application.EnableEvents = True
Me.Protect Password:="edit" ' Lock the sheet
activeSheet.Calculate
End Sub