VBA Code for upcoming deadline pop-up - message to show info from 2 other columns plus # of days until deadline

aliecat08

New Member
Joined
Oct 18, 2017
Messages
14
Office Version
  1. 2013
Platform
  1. Windows
I am a complete VBA novice and searched this forum to solve my issue but I still can't figure it out. I have a workbook with 3 worksheets and need a pop-up when opening the workbook. All the info for the pop-up will be derived from the 1st sheet which is named "OpenCases"


Here is a screenshot of my columns:
1675119611643.png



I want the pop-up to show the First and Last Name of each person whose "Statute" is 60 days or less away AND "Status" is Pre-lit. So the message will state, for example, "Jane Doe statute expiring in 20 days", "Hotel Doe statute is 59 days away."

PLEASE HELP!
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Do you really need the pop-up? Or is it enough just to flag the rows that meet the condition? Like this?

Book1
ABCDEFG
1Last nameFirst nameDOLStatuteStatusAttorney(s)Assistant
2DOEALPHA3/8/20213/8/2023Pre-litRomeoWhiskey
3DOEBRAVO4/28/20214/28/2023Pre-litRomeoWhiskey
4DOECHARLIE9/30/202110/2/2023FiledRomeoWhiskey
5DOEDELTA9/13/20219/13/2023Pre-litRomeoWhiskey
6DOEECHO10/18/202110/18/2023FiledRomeoWhiskey
7DOEFOXTROT2/18/20212/20/2023Pre-litRomeoWhiskey
8DOEGOLF12/1/202112/1/2023FiledRomeoWhiskey
9DOEHOTEL5/10/20215/10/2023Pre-litRomeoWhiskey
10DOEINDIA5/19/20215/19/2023SettledRomeoWhiskey
11DOEGOLF12/1/202112/1/2023FiledRomeoWhiskey
12DOEHOTEL5/10/20215/10/2023Pre-litRomeoWhiskey
13DOEINDIA5/19/20215/19/2023SettledRomeoWhiskey
OpenCases
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A3:G13Expression=AND(($E3="Pre-lit"),(NETWORKDAYS(TODAY(),$D3,)<60))textNO
A2:G2Expression=AND(($E2="Pre-lit"),(NETWORKDAYS(TODAY(),$D2,)<60))textNO


The problem is if you have more than one that meets the Pre-lit and 60 days or less. Let's say you have 400 items that meet that condition. Do you want to have to 400 pop-ups that you have to hit OK? Or a single pop-up that has 400 lines on it.

Finally, what constitutes the 60 days? 60 calendar days? 60 business days? Does the 60 days include holidays? I went with straight business days using the =networkdays() function without the holidays parameter.
 
Upvote 0
I actually need the pop-up, not the conditional formatting. We're never going to have 400 lines. The max cases with statutes 60 days (calendar not business) will be less than 5. So I just need one pop-up with lines for each case meeting the criteria. The pop-up will look like this:

UPCOMING STATUTES:

ALPHA DOE (DOL: 3/8/2021) statute expiring in 20 days

FOXTROT DOE (DOL: 2/18/2021) statute expiring in 14 days
 
Upvote 0
1675194998330.png


Go to ThisWorkbook and add this code.

VBA Code:
Private Sub workbook_open()
    Dim LastRow As Long
    Dim srcrow As Long
    Dim popup_message As String
       
    LastRow = Cells(Rows.Count, 1).End(xlUp).Row
    popup_message = "UPCOMING STATUTES:" & vbNewLine & vbNewLine
   
    With Worksheets("OpenCases")
    For srcrow = 2 To LastRow                           'skip the title row so start at row 3
        If .Range("E" & srcrow) = "Pre-lit" Then        'Pre-lit is the first criteria
            If .Range("D" & srcrow) - Date < 60 Then    'Statute date < 60 days is the second criteria
                'Build message
                popup_message = popup_message & .Range("B" & srcrow) & " " & .Range("A" & srcrow) & " (DOL: "
                popup_message = popup_message & .Range("D" & srcrow) & ") statute expiring in " & .Range("D" & srcrow) - Date & " days"
                popup_message = popup_message & vbNewLine & vbNewLine
            End If
        End If
    Next
    End With
   
    MsgBox popup_message                                'display the popup with the message
End Sub
 
Upvote 0
Solution
I did but the pop up only shows "UPCOMING STATUTES:"

1675199030954.png


I copy pasted the exact code using the copy icon from your post. It looks like this:

VBA Code:
Private Sub workbook_open()
    Dim LastRow As Long
    Dim srcrow As Long
    Dim popup_message As String
       
    LastRow = Cells(Rows.Count, 1).End(xlUp).Row
    popup_message = "UPCOMING STATUTES:" & vbNewLine & vbNewLine
   
    With Worksheets("OpenCases")
    For srcrow = 2 To LastRow                           'skip the title row so start at row 3
        If .Range("E" & srcrow) = "Pre-lit" Then        'Pre-lit is the first criteria
            If .Range("D" & srcrow) - Date < 60 Then    'Statute date < 60 days is the second criteria
                'Build message
                popup_message = popup_message & .Range("B" & srcrow) & " " & .Range("A" & srcrow) & " (DOL: "
                popup_message = popup_message & .Range("D" & srcrow) & ") statute expiring in " & .Range("D" & srcrow) - Date & " days"
                popup_message = popup_message & vbNewLine & vbNewLine
            End If
        End If
    Next
    End With
   
    MsgBox popup_message                                'display the popup with the message
End Sub
 
Upvote 0
OH WAIT NM!! The workbook I tested on has the Status column under "G" not "E". Once I tweaked the code to reflect this, it worked.

THANK YOU THANK YOU THANK YOU!!!
 
Upvote 0
The code is looking for the Status (Pre-lit, Filed, etc) in column E like your first example. The one you just posted has the Status in column G. That is why it is not working.

Change this
VBA Code:
If .Range("E" & srcrow) = "Pre-lit" Then

to
VBA Code:
If .Range("G" & srcrow) = "Pre-lit" Then
 
Upvote 0
We both noticed that at the same time :)
Haha yup!

Can you PLEASEEE help me with another code for this workbook?

I want to move the entire row from the OpenCases sheet to ClosedCases sheet when "Status" column is changed to "Settled" or "Dropped" or "Closed". In the ClosedCases sheet, I want it autosorted by the "Last Name" column. I also want to do the reverse, in case we mistakenly move a case to ClosedCases sheet.

And ideally, a message that pops up before the move that confirms the move. Something like "Are you sure you want to move the case to Closed Cases?" and "Are you sure you want to move the case to Open Cases?"

When I first tried this 6 years ago, I got a code from some site but it's a complete mess and based on designated Names so the slight change causes a bunch of issues.

I'd really appreciate your help!!
 
Upvote 0
I think the best thing is to put this request into a separate post. That way if I cannot get to it, someone else might pick it up. If people see something is already answered, they may not want to read it.
 
Upvote 0

Forum statistics

Threads
1,223,880
Messages
6,175,157
Members
452,615
Latest member
bogeys2birdies

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