VBA or Formula to Calculate Years Between Dates and Highlight A Cell

Evernight2021

New Member
Joined
Dec 28, 2018
Messages
10
I have a spreadsheet with a column of dates (A) and anniversary dates (B). I want to make a column (C) with cells that calculate if the date in column B is equal to or greater than today's date. If so, I want them to subtract the date in column B1 from the date in A1 and put the number of years between them in C1 and then highlight the cell in a color to make the change stand out but I'm not sure what the best way to do this would be. I have the following formula that correctly calculates the years, but I can't figure out how to change the cell color when that value changes:

[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]
Code:
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]=IF(N45<=TODAY(),ROUNDDOWN((N45-D45)/360,0),ROUNDDOWN((N45-D45)/360,0)-1)[/FONT]

An example of the data is below:
[/FONT]
ABC
1DateAnniversaryYears
2
6/23/1997

<colgroup><col></colgroup><tbody>
</tbody>
6/23/201921
37/1/20017/1/201917
47/6/20047/6/201914
53/21/20163/21/20192

<tbody>
</tbody>

Any assistance on how to complete this goal or a better way to do it would be appreciated.

<colgroup><col><col><col><col><col><col><col><col><col><col><col></colgroup><tbody>
</tbody>
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
The formula should actually be

=IF(B1<=TODAY(),ROUNDDOWN((B1-A1)/365,0),ROUNDDOWN((B1-A1)/365,0)-1)

Forgot to modify it for the example.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,288
Messages
6,124,086
Members
449,141
Latest member
efex

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