Rayreloj10
New Member
- Joined
- Jun 26, 2023
- Messages
- 15
- Office Version
- 2019
- Platform
- Windows
Hello everyone,
I will try to explain again.
I'm trying to make a reminder for my letter log and I have more than 1 condition before it includes the letter number in the Msg Box. I have multiple sheet so I need to make the Msgbox appears everytime I click the sheets. I
here's my code I create. The code already works, however its displaying all the letter number in the cell. Msgbox should only display the letter number if it shows the value in the other cell as "OPEN".
really appriciate your help. Thank you in advance.
As you can see below, the condition is if the the DUEDATE is not empty and it is greater than or equal to the current Date -2. now I need to add one more condition. so then: if the DUEDATE is not empty and it is greater or equal to the current date -2 AND if the Status is "Open".
I will try to explain again.
I'm trying to make a reminder for my letter log and I have more than 1 condition before it includes the letter number in the Msg Box. I have multiple sheet so I need to make the Msgbox appears everytime I click the sheets. I
here's my code I create. The code already works, however its displaying all the letter number in the cell. Msgbox should only display the letter number if it shows the value in the other cell as "OPEN".
really appriciate your help. Thank you in advance.
As you can see below, the condition is if the the DUEDATE is not empty and it is greater than or equal to the current Date -2. now I need to add one more condition. so then: if the DUEDATE is not empty and it is greater or equal to the current date -2 AND if the Status is "Open".
A | B | C | D | E |
Letter Number | Title | Issued Date | Due Date | Status |
00001 | Letter1 | 26/Jun/23 | 11/July/23 | Open |
00002 | Letter2 | 25/Jun/23 | 10/july/23 | Closed |
VBA Code:
Option Explicit
Private Sub Worksheet_Activate()
Dim DateDueCol As Range
Dim DateDue As Range
Dim NotificationMsg As String
Dim LetterStatus As Range
Dim Status As Range
Set DateDueCol = ActiveWorkbook.Sheets("2023").Range("L10:L373")
'Set LetterStatus = ThisWorkbook.Sheets("2023").Range("N10:N373")
For Each DateDue In DateDueCol
If DateDue <> "" And Date >= DateDue - 2 Then
NotificationMsg = NotificationMsg & " " & DateDue.Offset(0, -11)
'ActiveWorkbook.Sheets("Register").Range("A10")
End If
Next DateDue
If NotificationMsg = "" Then
MsgBox "We don't have any pending letter response."
Else: MsgBox "Reminder: We have a pending letters." & vbCrLf & vbCrLf & vbCrLf & NotificationMsg
' ActiveWorkbook.Sheets("Register").Activate
End If
End Sub