KyleJackMorrison
Board Regular
- Joined
- Dec 3, 2013
- Messages
- 107
- Office Version
- 365
- 2021
- 2019
- Platform
- Windows
Hello,
I have a code that displays a msgbox when it reaches the date +1.
What I'm trying to do is get the code to display the message box if the date in column H9:H100 is over Now()+30 (Today + 30 days) and to continue displaying the expiry message (even after +30 days) until the date has changed.
Here is the code i have so far:
As you can see the code only finds dates with today's date +1.
I have tried something like:
But that seems to display the message box for everything including blank cells. (which results in me frantically spamming ESC).
Any help is appreciated.
KJM
I have a code that displays a msgbox when it reaches the date +1.
What I'm trying to do is get the code to display the message box if the date in column H9:H100 is over Now()+30 (Today + 30 days) and to continue displaying the expiry message (even after +30 days) until the date has changed.
Here is the code i have so far:
Code:
Sub ExpiryDateA()
Dim rowNumber As Long
Dim thisSheet As Worksheet
Dim cellToCheck As Range
Dim ANum As String, ATitle As String, AName As String, ACourse As String
Dim ADate As String
Dim AResponse As Integer
Set thisSheet = ActiveSheet 'Makes the sheet active
For rowNumber = 9 To thisSheet.Cells(Rows.Count, 8).End(xlUp).Row
Set cellToCheck = thisSheet.Cells(rowNumber, 8) 'cells to check 'S'
If cellToCheck.Value = DateAdd("d", 1, Date) Then
ANum = Sheets("1 Course Sheet").Range("D" & rowNumber).Value
ATitle= Sheets("1 Course Sheet").Range("E" & rowNumber).Value
AName = Sheets("1 Course Sheet").Range("F" & rowNumber).Value
ACourse= Sheets("1 Course Sheet").Range("H7").Value
ADate = Sheets("1 Course Sheet").Range("H" & rowNumber).Value
AResponse = MsgBox("" & ATitle & " " & AName & "'s " & ACourse & " has expired on: " & Format(ADate, "dddd dd mmmm yyyy") & "." & _
vbNewLine & vbNewLine & "Please book " & ATitle & " " & AName & " this course again.", vbCritical, "Due date course") 'Message Box
End If
NextLine:
Next rowNumber
End Sub
As you can see the code only finds dates with today's date +1.
I have tried something like:
Code:
If cellToCheck.Value < DateAdd("d", 30, Date) Then
But that seems to display the message box for everything including blank cells. (which results in me frantically spamming ESC).
Any help is appreciated.
KJM