Checking for and incrementing a year in a date

Evernight2021

New Member
Joined
Dec 28, 2018
Messages
10
I have a column that contains mostly dates (and some column headers and blank spaces) in MM/DD/YYYY format. I want to automatically increment the year for all of the dates in this column.

I know that the following code increments the year of one cell:

Code:
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]=DATE(YEAR(A1)+1,MONTH(A1),DAY(A1))[/FONT]

However, how do I check the entire column, pick out just the dates and apply that formula to them?
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Hi,

If the column contains either a Date, Blank, or Headers (that are Text, or Alpha numeric):


Book1
AB
1Header 
212/28/201812/28/2019
3
4Header 2
512/29/201812/29/2019
6
712/30/201812/30/2019
8
9
10Header 3
11
1212/31/201812/31/2019
Sheet431
Cell Formulas
RangeFormula
B1=IF(ISNUMBER(A1),EDATE(A1,12),"")


I've used the EDATE function rather than the DATE function, you can use either.

B1 formula copied down.
 
Last edited:
Upvote 0
Yes, VBA can definitely do that, and you originally asked about a formula, I'm more of a formula guy, so I'm sure someone else can help you with doing that in VBA.

Have a nice day.
 
Upvote 0
My apologies for not being more clear. I'm looking to use a push button to increment the dates so I can control when they increment.
 
Upvote 0
I have an idea for you.

If you want to be able to control When and How Many years to Increase Or Decrease Column A (in my sample) years, you can consider this modification to my formula above.
In D2, enter the number of years you want increased, if you enter a negative number, say -2 (minus 2), the year will Decrease by 2 years, positive numbers will Increase the years accordingly, if left Blank or 0 (zero) entered, no change.


Book1
ABCD
1Header Years to Increse/Decrease
212/28/201812/28/20191
3
4Header 2
512/29/201812/29/2019
6
712/30/201812/30/2019
8
9
10Header 3
11
1212/31/201812/31/2019
Sheet431
Cell Formulas
RangeFormula
B1=IF(ISNUMBER(A1),EDATE(A1,D$2*12),"")
 
Upvote 0
Here is a macro for you to try...
Code:
[table="width: 500"]
[tr]
	[td]Sub IncreaseDatesByOneYear()
  Dim R As Long
  For R = 1 To Cells(Rows.Count, "A").End(xlUp).Row
    If IsDate(Cells(R, "A").Value) Then Cells(R, "A").Value = DateAdd("yyyy", 1, Cells(R, "A").Value)
  Next
End Sub[/td]
[/tr]
[/table]
 
Upvote 0
Or this one:
Code:
Sub Add_A_Year()
    Dim a As String
    a = "A1:A" & Cells(Rows.Count, "A").End(xlUp).Row
    Range(a) = Evaluate("IF(ISNUMBER(" & a & "),EDATE(" & a & "+0,12)," & a & "&"""")")
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,825
Messages
6,121,788
Members
449,049
Latest member
greyangel23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top