Pop up Alert When Workbook is Opened

Gos-C

Active Member
Joined
Apr 11, 2005
Messages
258
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi all,

I have a worksheet with range A4:Y1504. Column M is used for dispensed dates, column Y is used for closed date, and column V is used to entered the word "rebill" – if required.

When the workbook is opened, if column V contains the word “rebill”, and column Y is blank, and the dispensed date in column M is more than 7 days older than the current date, I want the following message to pop up “You have one or more “rebill” item(s) past due. Please review the row(s) highlighted black.”

I tried the following (but without any success):

Code:
Option Explicit
Private Sub Workbook_Open()
Dim rngD As Range, rngR As Range, rngC As Range, dispD As Date, rblD As Date, v As String
rngD = Range("M4:M1504")
rngR = Range("V4:V1504")
rngC = Range("Y4:Y1504")
If (rngC = "" And rngR = "rebill" And rngD < Now() - 7) Then
    MsgBox "You have one or more ''rebill'' item(s) past due.  Please review the row(s) highlighted black.", vbInformation, Title:="Rebill Alert"
End If
End Sub

The worksheet is set up to highlight the row in black if the above conditions are true.

Can someone please help me with the code.

Thank you,
Gos-C
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Try something like this perhaps?
Code:
Option Explicit
Private Sub Workbook_Open()
    Dim i As Integer

    With Worksheets("Sheet1")
        For i = 4 To 1504
            If (.Cells(i, 25).Value = "" And .Cells(i, 22).Value = "rebill" And .Cells(i, 13).Value < Now() - 7) Then
                MsgBox "You have one or more ''rebill'' item(s) past due.  Please review the row(s) highlighted black.", vbInformation, Title:="Rebill Alert"
            End If
        Next i
    End With
    
End Sub
 
Upvote 0
Works perfectly!

Thank you very much, Sal Paraside.

Gos-C
 
Upvote 0

Forum statistics

Threads
1,214,990
Messages
6,122,626
Members
449,093
Latest member
catterz66

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top