charlie2503
New Member
- Joined
- May 26, 2022
- Messages
- 13
- Office Version
- 365
- 2021
- Platform
- MacOS
Hi everyone,
I am new to VBA and am desperate for some help.
I am working on an excel file containing a list of food product certifications. I have multiple columns (L, N, and X) listing the due dates for 3 different certifications.
Certifications 1 and 3 (in columns L and X) need an alert that is 1 year earlier than the listed due date, while certification 2 only needs an alert 6 months earlier.
I have copied a code that creates a pop-up for certification 1 successfully, but how do I apply this for certifications 2 and 3 with due dates listed in different columns?
Also, is it possible use this code if the file has multiple tabs (considering each tab has the 3 different due dates listed in columns L, N, and X as well).
I'm really struggling with this and would appreciate your help.
Here's the code that I use:
Private Sub Workbook_Open()
Dim RegNumberValidUntilCol As Range
Dim RegNumberValidUntil As Range
Dim NotificationMsg As String
Set RegNumberValidUntilCol = Range("L2:L19")
For Each RegNumberValidUntil In RegNumberValidUntilCol
If RegNumberValidUntil <> "" And RegNumberValidUntil - Date <= 365 Then
NotificationMsg = NotificationMsg & " " & RegNumberValidUntil.Offset(0, -9)
End If
Next RegNumberValidUntil
If NotificationMsg = "" Then
MsgBox "You do not have any product registrations expiring soon."
Else: MsgBox "Registrations of the following products are expiring soon: " & NotificationMsg
End If
End Sub
I am new to VBA and am desperate for some help.
I am working on an excel file containing a list of food product certifications. I have multiple columns (L, N, and X) listing the due dates for 3 different certifications.
Certifications 1 and 3 (in columns L and X) need an alert that is 1 year earlier than the listed due date, while certification 2 only needs an alert 6 months earlier.
I have copied a code that creates a pop-up for certification 1 successfully, but how do I apply this for certifications 2 and 3 with due dates listed in different columns?
Also, is it possible use this code if the file has multiple tabs (considering each tab has the 3 different due dates listed in columns L, N, and X as well).
I'm really struggling with this and would appreciate your help.
Here's the code that I use:
Private Sub Workbook_Open()
Dim RegNumberValidUntilCol As Range
Dim RegNumberValidUntil As Range
Dim NotificationMsg As String
Set RegNumberValidUntilCol = Range("L2:L19")
For Each RegNumberValidUntil In RegNumberValidUntilCol
If RegNumberValidUntil <> "" And RegNumberValidUntil - Date <= 365 Then
NotificationMsg = NotificationMsg & " " & RegNumberValidUntil.Offset(0, -9)
End If
Next RegNumberValidUntil
If NotificationMsg = "" Then
MsgBox "You do not have any product registrations expiring soon."
Else: MsgBox "Registrations of the following products are expiring soon: " & NotificationMsg
End If
End Sub