View Single Post
 
Old 11-30-2019, 08:37 AM
PrincessApril PrincessApril is offline Windows 10 Office 2019
Competent Performer
 
Join Date: Nov 2019
Posts: 102
PrincessApril is on a distinguished road
Default

I found a proposed solution on another forum, but the code does not work for me (I don't see any reaction after I open the workbook...perhaps it needs updating or fixing):

Quote:
Code:
Private Sub Worksheet_Activate()
   Dim N As Long, r As Range, rng As Range
   Dim d As Date
   N = Cells(Rows.Count, "G").End(xlUp).Row
   Set rng = Range("G3:G" & N)

   For Each r In rng
      If IsDate(r.Value) Then
         d = r.Value
         If d < Date Then
            r.Value = DateSerial(Year(d) + 1, Month(d), Day(d))
         End If
      End If
   Next r
End Sub
Source: microsoft excel - How do I add 1 year to a specific date once that date has passed? - Super User

Any ideas on what the problem with that code might be? I did the following:
  • Saved my workbook as xlsm
  • Hit Alt + 11 and pasted the code
  • Changed G3 to G6 to match the first cell of data in my worksheet
  • Saved and Reopened the workbook.
  • Accepted the "enable content" notification, saved and reopened again, but the old date does not update (I have cell G6 as June 7, 2018, for testing but it does not update).

Last edited by PrincessApril; 11-30-2019 at 11:22 AM.
Reply With Quote