Conditional Formatting question

AlstarOC

New Member
Joined
Dec 21, 2010
Messages
4
Hello!!
I have built (with help) a spreadsheet that tracks different expiry dates, for training tickets, driver's licenses, course renewals etc...
I would like to try and add a birthday alert, or conditional formatting to highlight birthdays, using the driver's license expiry date.
But, because I am tracking expiry dates by day-month-year, I can't figure out how to conditionally format using the day and month only, not including the year. So, This is what I would like to do: If my driver's license expires on 19-May-2016, this cell would highlight pink on May 19th of every year.
Is this possible?
Thanks!!:stickouttounge:
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
This macro will work when run manually for a defined range
Code:
Sub Birthdays()
Dim c As Range
MyDate = Format(Now(), "mm/dd")
With Range("A1:A4").Interior
        .Pattern = xlNone
        .TintAndShade = 0
        .PatternTintAndShade = 0
End With
For Each c In Range("A1:A4")
If Format(c, "mm/dd") = MyDate Then
    With c.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .ThemeColor = xlThemeColorAccent2
        .TintAndShade = 0.799981688894314
        .PatternTintAndShade = 0
    End With
End If
Next c
End Sub

You could set it up to run when the workbook is opened, but it would need modifications
 
Upvote 0
Probably going to shock you here, but I am not confident in my macro recording skills...I just tried, I don't get it. lol
I take it there is no simple rule I could set?
 
Upvote 0
Sorry for the crude example, this is how it looks, columns running from A-H, and yes, names get added and deleted quite often. Right now, I have about 167 people on this list, in column C. (names deleted) Notice, that the Driver's License date is only column J, that is the only column I would use for the birthday reminder.

<TABLE style="WIDTH: 632pt; BORDER-COLLAPSE: collapse" border=0 cellSpacing=0 cellPadding=0 width=842><COLGROUP><COL style="WIDTH: 16pt; mso-width-source: userset; mso-width-alt: 768" span=2 width=21><COL style="WIDTH: 94pt; mso-width-source: userset; mso-width-alt: 4571" width=125><COL style="WIDTH: 59pt; mso-width-source: userset; mso-width-alt: 2889" width=79><COL style="WIDTH: 61pt; mso-width-source: userset; mso-width-alt: 2962" width=81><COL style="WIDTH: 59pt; mso-width-source: userset; mso-width-alt: 2889" width=79><COL style="WIDTH: 57pt; mso-width-source: userset; mso-width-alt: 2779" width=76><COL style="WIDTH: 54pt; mso-width-source: userset; mso-width-alt: 2633" span=5 width=72><TBODY><TR style="HEIGHT: 21.75pt; mso-height-source: userset" height=29><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5 0.5pt solid; BACKGROUND-COLOR: #ddd9c3; WIDTH: 16pt; HEIGHT: 21.75pt; BORDER-TOP: #a5a5a5 0.5pt solid; BORDER-RIGHT: #a5a5a5 0.5pt solid" class=xl67 height=29 width=21>O</TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5; BACKGROUND-COLOR: #ddd9c3; WIDTH: 16pt; BORDER-TOP: #a5a5a5 0.5pt solid; BORDER-RIGHT: #a5a5a5 0.5pt solid" class=xl67 width=21>M</TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5; BACKGROUND-COLOR: #ddd9c3; WIDTH: 94pt; BORDER-TOP: #a5a5a5 0.5pt solid; BORDER-RIGHT: #a5a5a5 0.5pt solid" class=xl75 width=125>Name</TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5; BACKGROUND-COLOR: #ddd9c3; WIDTH: 59pt; BORDER-TOP: #a5a5a5 0.5pt solid; BORDER-RIGHT: #a5a5a5 0.5pt solid" class=xl75 width=79>Orientation Taken Date</TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5; BACKGROUND-COLOR: #ddd9c3; WIDTH: 61pt; BORDER-TOP: #a5a5a5 0.5pt solid; BORDER-RIGHT: #ece9d8" class=xl79 width=81>Hire Date</TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #ece9d8 1pt; BACKGROUND-COLOR: #ddd9c3; WIDTH: 59pt; BORDER-TOP: #a5a5a5 0.5pt solid; BORDER-RIGHT: #a5a5a5 0.5pt solid" class=xl68 width=79>FirstAIDDate Expiry</TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5; BACKGROUND-COLOR: #ddd9c3; WIDTH: 57pt; BORDER-TOP: #a5a5a5 0.5pt solid; BORDER-RIGHT: #a5a5a5 0.5pt solid" class=xl70 width=76>H2SDate Expiry </TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5; BACKGROUND-COLOR: #ddd9c3; WIDTH: 54pt; BORDER-TOP: #a5a5a5 0.5pt solid; BORDER-RIGHT: #a5a5a5 0.5pt solid" class=xl70 width=72>WHMIS Expiry Date</TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5; BACKGROUND-COLOR: #ddd9c3; WIDTH: 54pt; BORDER-TOP: #a5a5a5 0.5pt solid; BORDER-RIGHT: #a5a5a5 0.5pt solid" class=xl70 width=72>TDG Expiry Date</TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5; BACKGROUND-COLOR: #ddd9c3; WIDTH: 54pt; BORDER-TOP: #a5a5a5 0.5pt solid; BORDER-RIGHT: #a5a5a5 0.5pt solid" class=xl70 width=72>DriverLicense Expiry Date </TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5; BACKGROUND-COLOR: #ddd9c3; WIDTH: 54pt; BORDER-TOP: #a5a5a5 0.5pt solid; BORDER-RIGHT: #a5a5a5 0.5pt solid" class=xl70 width=72>Drug Tested Taken Date</TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5; BACKGROUND-COLOR: #ddd9c3; WIDTH: 54pt; BORDER-TOP: #a5a5a5 0.5pt solid; BORDER-RIGHT: #ece9d8 1pt" class=xl73 width=72>Fit test Taken Date</TD></TR><TR style="HEIGHT: 10.5pt; mso-height-source: userset" height=14><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5 0.5pt solid; BACKGROUND-COLOR: transparent; HEIGHT: 10.5pt; BORDER-TOP: #a5a5a5; BORDER-RIGHT: #a5a5a5 0.5pt solid" class=xl65 height=14>f</TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5; BACKGROUND-COLOR: transparent; BORDER-TOP: #a5a5a5; BORDER-RIGHT: #a5a5a5 0.5pt solid" class=xl65>C</TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5; BACKGROUND-COLOR: transparent; WIDTH: 94pt; BORDER-TOP: #a5a5a5; BORDER-RIGHT: #a5a5a5 0.5pt solid" class=xl76 width=125> </TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5; BACKGROUND-COLOR: transparent; WIDTH: 59pt; BORDER-TOP: #a5a5a5; BORDER-RIGHT: #a5a5a5 0.5pt solid" class=xl78 width=79>08-Apr-10</TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5; BACKGROUND-COLOR: transparent; WIDTH: 61pt; BORDER-TOP: #a5a5a5; BORDER-RIGHT: #ece9d8" class=xl80 width=81>08-Apr-10</TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #ece9d8 1pt; BACKGROUND-COLOR: transparent; WIDTH: 59pt; BORDER-TOP: #a5a5a5; BORDER-RIGHT: #a5a5a5 0.5pt solid" class=xl69 width=79>3-Aug-13</TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5 0.5pt solid; WIDTH: 57pt; FONT-FAMILY: Tahoma; BACKGROUND: #ffc7ce; COLOR: windowtext; FONT-SIZE: 8pt; BORDER-TOP: #a5a5a5 0.5pt solid; FONT-WEIGHT: 400; BORDER-RIGHT: #a5a5a5 0.5pt solid; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl71 width=76>28-Mar-2011T</TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5; BACKGROUND-COLOR: transparent; WIDTH: 54pt; BORDER-TOP: #a5a5a5; BORDER-RIGHT: #a5a5a5 0.5pt solid" class=xl71 width=72>8-Apr-13</TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5; BACKGROUND-COLOR: transparent; WIDTH: 54pt; BORDER-TOP: #a5a5a5; BORDER-RIGHT: #a5a5a5 0.5pt solid" class=xl71 width=72>8-Apr-13</TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5; BACKGROUND-COLOR: transparent; WIDTH: 54pt; BORDER-TOP: #a5a5a5; BORDER-RIGHT: #a5a5a5 0.5pt solid" class=xl71 width=72>5-Mar-15</TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5; BACKGROUND-COLOR: transparent; WIDTH: 54pt; BORDER-TOP: #a5a5a5; BORDER-RIGHT: #a5a5a5 0.5pt solid" class=xl71 width=72>16-Apr-10</TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5; BACKGROUND-COLOR: transparent; WIDTH: 54pt; BORDER-TOP: #a5a5a5; BORDER-RIGHT: #ece9d8 1pt" class=xl74 width=72>23-Jun-10</TD></TR><TR style="HEIGHT: 10.5pt; mso-height-source: userset" height=14><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5 0.5pt solid; BACKGROUND-COLOR: transparent; HEIGHT: 10.5pt; BORDER-TOP: #a5a5a5; BORDER-RIGHT: #a5a5a5 0.5pt solid" class=xl65 height=14>f</TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5; BACKGROUND-COLOR: transparent; BORDER-TOP: #a5a5a5; BORDER-RIGHT: #a5a5a5 0.5pt solid" class=xl65>J</TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5; BACKGROUND-COLOR: transparent; WIDTH: 94pt; BORDER-TOP: #a5a5a5; BORDER-RIGHT: #a5a5a5 0.5pt solid" class=xl76 width=125> </TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5; BACKGROUND-COLOR: transparent; WIDTH: 59pt; BORDER-TOP: #a5a5a5; BORDER-RIGHT: #a5a5a5 0.5pt solid" class=xl78 width=79>28-Dec-10</TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5 0.5pt solid; WIDTH: 61pt; FONT-FAMILY: Tahoma; BACKGROUND: #92d050; COLOR: windowtext; FONT-SIZE: 8pt; BORDER-TOP: #a5a5a5 0.5pt solid; FONT-WEIGHT: 400; BORDER-RIGHT: #ece9d8; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl80 width=81>28-Dec-10</TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #ece9d8 1pt; WIDTH: 59pt; FONT-FAMILY: Tahoma; BACKGROUND: red; COLOR: windowtext; FONT-SIZE: 8pt; BORDER-TOP: #a5a5a5 0.5pt solid; FONT-WEIGHT: 400; BORDER-RIGHT: #a5a5a5 0.5pt solid; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl69 width=79> </TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5; BACKGROUND-COLOR: transparent; WIDTH: 57pt; BORDER-TOP: #a5a5a5; BORDER-RIGHT: #a5a5a5 0.5pt solid" class=xl71 width=76>12-Aug-13</TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5; BACKGROUND-COLOR: transparent; WIDTH: 54pt; BORDER-TOP: #a5a5a5; BORDER-RIGHT: #a5a5a5 0.5pt solid" class=xl71 width=72>27-Dec-13</TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5; BACKGROUND-COLOR: transparent; WIDTH: 54pt; BORDER-TOP: #a5a5a5; BORDER-RIGHT: #a5a5a5 0.5pt solid" class=xl71 width=72>27-Dec-13</TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5 0.5pt solid; WIDTH: 54pt; FONT-FAMILY: Tahoma; BACKGROUND: #ffc000; COLOR: windowtext; FONT-SIZE: 8pt; BORDER-TOP: #a5a5a5 0.5pt solid; FONT-WEIGHT: 400; BORDER-RIGHT: #a5a5a5 0.5pt solid; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl71 width=72>DNH</TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5; BACKGROUND-COLOR: transparent; WIDTH: 54pt; BORDER-TOP: #a5a5a5; BORDER-RIGHT: #a5a5a5 0.5pt solid" class=xl71 width=72>28-Dec-10</TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5; BACKGROUND-COLOR: transparent; WIDTH: 54pt; BORDER-TOP: #a5a5a5; BORDER-RIGHT: #ece9d8 1pt" class=xl74 width=72>28-Dec-10</TD></TR><TR style="HEIGHT: 10.5pt; mso-height-source: userset" height=14><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5 0.5pt solid; BACKGROUND-COLOR: transparent; HEIGHT: 10.5pt; BORDER-TOP: #a5a5a5; BORDER-RIGHT: #a5a5a5 0.5pt solid" class=xl65 height=14>f</TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5; BACKGROUND-COLOR: transparent; BORDER-TOP: #a5a5a5; BORDER-RIGHT: #a5a5a5 0.5pt solid" class=xl65>J</TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5; BACKGROUND-COLOR: transparent; WIDTH: 94pt; BORDER-TOP: #a5a5a5; BORDER-RIGHT: #a5a5a5 0.5pt solid" class=xl76 width=125> </TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5; BACKGROUND-COLOR: transparent; WIDTH: 59pt; BORDER-TOP: #a5a5a5; BORDER-RIGHT: #a5a5a5 0.5pt solid" class=xl78 width=79>22-Feb-11</TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5 0.5pt solid; WIDTH: 61pt; FONT-FAMILY: Tahoma; BACKGROUND: #92d050; COLOR: windowtext; FONT-SIZE: 8pt; BORDER-TOP: #a5a5a5 0.5pt solid; FONT-WEIGHT: 400; BORDER-RIGHT: #ece9d8; TEXT-DECORATION: none; mso-pattern: black none; text-underline-style: none; text-line-through: none" class=xl80 width=81>22-Feb-11</TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #ece9d8 1pt; BACKGROUND-COLOR: transparent; WIDTH: 59pt; BORDER-TOP: #a5a5a5; BORDER-RIGHT: #a5a5a5 0.5pt solid" class=xl69 width=79>N/A</TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5; BACKGROUND-COLOR: transparent; WIDTH: 57pt; BORDER-TOP: #a5a5a5; BORDER-RIGHT: #a5a5a5 0.5pt solid" class=xl71 width=76>N/A</TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5; BACKGROUND-COLOR: transparent; WIDTH: 54pt; BORDER-TOP: #a5a5a5; BORDER-RIGHT: #a5a5a5 0.5pt solid" class=xl71 width=72>22-Feb-14</TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5; BACKGROUND-COLOR: transparent; WIDTH: 54pt; BORDER-TOP: #a5a5a5; BORDER-RIGHT: #a5a5a5 0.5pt solid" class=xl71 width=72>22-Feb-14</TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5; BACKGROUND-COLOR: transparent; WIDTH: 54pt; BORDER-TOP: #a5a5a5; BORDER-RIGHT: #a5a5a5 0.5pt solid" class=xl71 width=72>N/A</TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5; BACKGROUND-COLOR: transparent; WIDTH: 54pt; BORDER-TOP: #a5a5a5; BORDER-RIGHT: #a5a5a5 0.5pt solid" class=xl71 width=72>22-Feb-11</TD><TD style="BORDER-BOTTOM: #a5a5a5 0.5pt solid; BORDER-LEFT: #a5a5a5; BACKGROUND-COLOR: transparent; WIDTH: 54pt; BORDER-TOP: #a5a5a5; BORDER-RIGHT: #ece9d8 1pt" class=xl74 width=72>22-Feb-11</TD></TR></TBODY></TABLE>
 
Upvote 0
Okay, I have assumed that there will always be a value in the Name column, C, for as long as there is data.

Open your workbook, save as a new version, just in case.
Hit Alt + F11 to open the Visual Basic Editor. Go to Insert - > Module.
Paste the following code into the window.
Close the Visual Basic Editor. Save the workbook.

To run the macro-

in 2003 go to Tools - > Macro -> Macros - > Click on the Macro name and choose run

in 2007 go to View -> Macros -> Click on the Macro name and choose run.

If all is well, save over your original workbook.

Code:
Sub Birthdays()
Dim lastRow As Long
Dim c As Range

MyDate = Format(Now(), "mm/dd")
lastRow = Range("C" & Rows.Count).End(xlUp).Row
With Range("J2:J" & lastRow).Interior
        .Pattern = xlNone
        .TintAndShade = 0
        .PatternTintAndShade = 0
End With
For Each c In Range("J2:J" & lastRow)
If Format(c, "mm/dd") = MyDate Then
    With c.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .ThemeColor = xlThemeColorAccent2
        .TintAndShade = 0.799981688894314
        .PatternTintAndShade = 0
    End With
End If
Next c
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

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