The following will send a message (insert as appropriate) if the worksheet is opened on a weekday and a message has not already been sent. The code adds the year to column D to record the fact that this year the message has been sent. Note Sunday is weekday1 and Saturday is weekday 7, so you can use this to determine what to do with birthdays that fall on the weekend.
Sub Bdwishes() Dim i As Long Dim ws As Worksheet Dim bSendMessage As Boolean Dim dBirthday As Date Set ws = ThisWorkbook.Sheets("Sheet1") With ws For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row bSendMessage = False dBirthday = CDate(.Range("C" & i).Value) Select Case True Case Day(Now()) = Day(dBirthday) And Month(Now()) = Month(dBirthday) 'birthday this day bSendMessage = True End Select If bSendMessage Then If Weekday(dBirthday) > 1 And Weekday(dBirthday) < 7 Then 'the birthday is a weekday If .Range("D" & i).Value < Year(Now) Then 'send birthday message MsgBox "send message" 'update year message sent .Range("D" & i).Value = Year(Now) End If End If End If Next i End With End Sub




Reply With Quote