How to Highlight a Birthday Automatically

In this article, you will see how you can change color when a Birthday is coming up without using a macro.

Step 1: Add today's date

First of all, add the current date in a new column using the function TODAY().

=TODAY()

Step 2: Months until birthday

In a new column, calculate the number of months remaining until the birthday.

Use the DATEDIF function and the parameter "ym" (number of months in the current year).

=DATEDIF(C2;D2;"ym")

Step 3: Days until birthday

In the same way, we calculate the number of days until the birthday.

Use the function DATEDIF again but with the value"md" this time for the third argument.

=DATEDIF(C2;D2;"md")

Step 4: Analyze the result

As you can see on the picture

  • If the birthday is soon, the value of the number of days and months is large
  • On the other hand, if the birthday is right around now, both value are close to 0

In this situation, it is not easy to generate a warning when a birthday is coming up. Except if you add a visual reminder 😉😋💡

Step 5: Add a reminder

Decide how many days before the birthday you want to set a reminder and enter this into another cell. In the example below I have added 7 days in cell I2. Change the previous formula to include this value as per the example below.

The formula for months becomes

=DATEDIF(C2-$I$2;D2;"ym")

The formula for days becomes

=DATEDIF(C2-$I$2 ;D2;"md")

Write the reference of the delay with an absolute reference. In this example that would be $I$2.

Step 6: Test whether or not to display a reminder

The test for the month is really easy because the value must be 0.

=E2=0

The test for the days is not complex but it is clever. We will test if the difference between days until birthday and reminder is lower than or equal to the reminder.

The test is:

=F2<=$I$2

Merge these 2 tests into a single one with the logical operator AND.

=AND(E2=0,F2<=$I$2)

The test returns TRUE if the number of days until the birthday is less than or equal to the reminder. However, it isn't really easy to identify which cells return TRUE at first glance. This is why we are going to write this test in a conditional formatting rule.

Step 7: Add conditional formatting

  • Firstly, copy the formula of the test (with the AND)
  • Open the menu Home > Conditional Formatting > New rule
  • Select the option Use a formula to determine which cells to format
  • Paste the formula
  • Customize the format when the rule is TRUE (here font color: white and background: red)

Step 8: Change the data range for conditional formatting

The final step is to apply this conditional formatting to the whole column.

  • Open the menu Home > Conditional Formatting > Manage rules
  • In the text box Apply to, select the range of cells to apply the conditional formatting to.

The final result is displayed below:

Related posts


Permanent link to this article: https://www.excel-exercise.com/how-to-highlight-birthday-automatically/


Leave a Reply

Your email address will not be published.