ayman110229
New Member
- Joined
- Aug 31, 2022
- Messages
- 5
- Office Version
- 2016
- Platform
- Windows
Hi,
I'm new to VBA and still learning. I'm trying to use VBA to create alar Pop-ups for Vaccination Due Dates but whenever I use a range of cells the macro wont run from some reason. Here's what I mean:
Option Explicit
Sub Due_Date()
Dim DueDate_Col As Range
Dim Due As Range
Dim PopUp_Notification As String
Set DueDate_Col = Range("D9:D54")
For Each Due In DueDate_Col
If Due <> "" And Date >= Due - Range("F9:F54") Then
PopUp_Notification = PopUp_Notification & " " & Due.Offset(0, -2)
End If
Next Due
If PopUp_Notification = "" Then
MsgBox "No Vaccinations are Due."
Else: MsgBox "These Dogs Need to be Vaccinated: " & PopUp_Notification
End If
End Sub
The bold underlined part always comes back with an error. But it works only if I choose 1 cell for example "F9" how can I fix this.
Thank you
I'm new to VBA and still learning. I'm trying to use VBA to create alar Pop-ups for Vaccination Due Dates but whenever I use a range of cells the macro wont run from some reason. Here's what I mean:
Option Explicit
Sub Due_Date()
Dim DueDate_Col As Range
Dim Due As Range
Dim PopUp_Notification As String
Set DueDate_Col = Range("D9:D54")
For Each Due In DueDate_Col
If Due <> "" And Date >= Due - Range("F9:F54") Then
PopUp_Notification = PopUp_Notification & " " & Due.Offset(0, -2)
End If
Next Due
If PopUp_Notification = "" Then
MsgBox "No Vaccinations are Due."
Else: MsgBox "These Dogs Need to be Vaccinated: " & PopUp_Notification
End If
End Sub
The bold underlined part always comes back with an error. But it works only if I choose 1 cell for example "F9" how can I fix this.
Thank you