Excel VBA pop up message help

Status
Not open for further replies.

Josh381991

New Member
Joined
Nov 9, 2022
Messages
6
Office Version
  1. 2007
Platform
  1. Windows
Good afternoon,

I am super new to VBA and hoping for some help.

I have a training log for all employees which lists modules and dates of expiry. I am attempting to get a pop up that automatically tells me what employees have outstanding training due. I used and amended a code from the internet which I have posted below. This works to a degree in that it pulls up what is expiring but it pulls up the dates rather than the employees name as shown below.

The employees names are in column A5 to A37 with the modules being in Row 4 to column AO. The dates are within A5 to AO37.

The H1 bit in the code allows me to set number of days I wish to search ie all dates occurring within the next X days.

Ideally I would like the pop up to come up saying training due for the following employees. Employee A Module C Employee D Module X etc.

I really hope that makes sense.

Sub Due_Date()
Dim DueDate_Col As Range
Dim Due As Range
Dim PopUp_Notification As String
Set DueDate_Col = Range("C5:AO37")
For Each Due In DueDate_Col
If Due <> "" And Date >= Due - Range("H1") Then
PopUp_Notification = PopUp_Notification & " " & Due.Offset(0, -2)
End If
Next Due
If PopUp_Notification = "" Then
MsgBox "No outstanding training"
Else: MsgBox "Training due for these individuals: " & PopUp_Notification
End If
End Sub


Thank you in advance.
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Try modifying the PopUp_Notification line to
VBA Code:
PopUp_Notification = PopUp_Notification & vbCrLf & Cells(Due.row, "A") & ": " & Due.Offset(0, -2)
This will output the Name and the date.

If it is useful, you might get the address of the cell containing the expiring date by replacing Due.Offset(0, -2) with Due.Address(0, 0)
 
Upvote 0
Try modifying the PopUp_Notification line to
VBA Code:
PopUp_Notification = PopUp_Notification & vbCrLf & Cells(Due.row, "A") & ": " & Due.Offset(0, -2)
This will output the Name and the date.

If it is useful, you might get the address of the cell containing the expiring date by replacing Due.Offset(0, -2) with Due.Address(0, 0)
Thanks Anthony,

This is now displaying the below;

1668070048495.png


Is it possible for me to add data from columns to this? In column 4 I have the different training modules listed from C4 to AK4.

Is it possible to get the pop up to say Employee C, Module B, 20/07/2023?

Thanks again for your help.
 
Upvote 0
Is it possible to get the pop up to say Employee C, Module B, 20/07/2023?
"Yes", but we don't know which is the layout of your information so cannot say which is the coding; a snapshot taken using XL2BB addin would gratly help, or at least a picture of the relevant data.

Btw, the msgbox will last until you press ok, and in the meantime the workbook is locked; wouldn't be better putting this information on a separate worksheet?
 
Upvote 0
"Yes", but we don't know which is the layout of your information so cannot say which is the coding; a snapshot taken using XL2BB addin would gratly help, or at least a picture of the relevant data.

Btw, the msgbox will last until you press ok, and in the meantime the workbook is locked; wouldn't be better putting this information on a separate worksheet?
Hi Anthony,

This is an example of the data on the spreadsheet:

1668076238234.png


Essentially I'm looking for the pop up the say Employee A Module A 11/04/2023

Thank you again :)
 
Upvote 0
Try:
VBA Code:
PopUp_Notification = PopUp_Notification & vbCrLf & Cells(Due.Row, "A") & " - " & Cells(1, Due.Column) & " - " & Due.Value
 
Upvote 0
Solution
Hello all,

Sorry to open this up again but in need of a little further help.

I have everything working as should be however the data set pulled no longer fits into the text box. Is there a way to get the alert box to write the information into word/notepad so i can view all of the data?
 
Upvote 0
Replace this portion:
Rich (BB code):
If PopUp_Notification = "" Then
MsgBox "No outstanding training"
Else: MsgBox "Training due for these individuals: " & PopUp_Notification
End If

with
VBA Code:
If PopUp_Notification = "" Then
    MsgBox "No outstanding training"
Else
   Dim WordApp As Object
   Dim WDoc As Object
'
    'Create Word.Application
    On Error Resume Next
        Set WordApp = GetObject(, "Word.Application")
    If Err.Number <> 0 Then
        Set WordApp = CreateObject("Word.Application")
        Err.Clear
    End If
    On Error GoTo 0
    WordApp.Visible = True
    Set WDoc = WordApp.Documents.Add
    WDoc.Range(0, 0).Text = PopUp_Notification
    WordApp.Activate
End If

This should create and show a word document
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,216,098
Messages
6,128,812
Members
449,468
Latest member
AGreen17

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