Birthday Formula in Excel
I was recently involved in a thread online where the problem was to trap a birthday based on a date of birth. The idea is to ignore the year and base the result on the day and month. After investigating I came up with the following formula:
=IF(AND(MONTH(C12)=MONTH(TODAY()),DAY(C12)=DAY(TODAY())),"Happy Birthday "&B12,"")
Where C12 contains the birthdate. The following will give the same result. If VBA is required.
Both methods are show above with the VBA returning to the status column. VBA is probably overkill
Option Explicit
Sub GetBday() 'Excel VBA to calculate birthdays
Dim dt As Integer
dt = Month(Date) & Day(Date)
Range("B12", Range("B" & Rows.Count).End(xlUp)).Offset(, -1) = "=MONTH(C12)&DAY(C12)"
Range("A11", Range("A" & Rows.Count).End(xlUp)).AutoFilter 1, dt
Range("C12", Range("C" & Rows.Count).End(xlUp)).Offset(, 1) = "=""HappyBirthday ""&RC[-2]"
[c11].AutoFilter
Columns(1).ClearContents
End Sub
Sub GetBday() 'Excel VBA to calculate birthdays
Dim dt As Integer
dt = Month(Date) & Day(Date)
Range("B12", Range("B" & Rows.Count).End(xlUp)).Offset(, -1) = "=MONTH(C12)&DAY(C12)"
Range("A11", Range("A" & Rows.Count).End(xlUp)).AutoFilter 1, dt
Range("C12", Range("C" & Rows.Count).End(xlUp)).Offset(, 1) = "=""HappyBirthday ""&RC[-2]"
[c11].AutoFilter
Columns(1).ClearContents
I have attached an Excel file with the above VBA procedure to show workings.