![]() |
|
|
|
#1
|
|||
|
|||
|
Here's the code, commented line by line for better understanding.
Code:
Sub UpdateIntakeDate()
Dim rng As Range 'the overall range to work on
Dim cel As Range 'the one cell to work on at a time
Dim lr As Long 'the last row with data in the column
With Sheets("Client Tracker")
'determine last used row in the column
lr = .Cells(.Rows.Count, "E").End(xlUp).Row
'if lr is less than first row that would have dates don't go any further
If lr < 6 Then Exit Sub '<<<<<<<<<<<<<
'set the range to work on
Set rng = .Range("E6:E" & lr)
'work on the cells in the range one at a time
For Each cel In rng
'if the cell IS NOT blank
If cel <> "" Then
'check if today is greater than or equal to the date in the cell plus one year
If Date >= DateAdd("yyyy", 1, cel) Then
'if it is then give it the new date
cel = DateSerial(Year(Date), Month(cel.Value), Day(cel.Value))
End If
End If
'move on to the next cel by going back to the start of For Each
Next cel
End With
End Sub
|
|
| Tags |
| automatically, update, year |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Auto update excel graph range, ignore data when date reads 00-Month-00
|
SavGDK | Excel | 2 | 06-24-2016 08:05 AM |
Auto populating dates on timesheet for week from one inputted date
|
ohi | Word VBA | 3 | 12-04-2014 12:11 PM |
| Date/Time Formula for Entry level XL user | talon1driver | Excel | 2 | 09-18-2014 02:32 PM |
| Mail merge with filter using data inputted by user | Tornado70 | Mail Merge | 6 | 04-09-2013 07:16 AM |
How to update automatically the “file name” as we do for the “Date”?
|
Jamal NUMAN | Word | 2 | 01-06-2011 02:43 PM |