How to stop a MsgBox from opening once a result has been chosen.

KyleJackMorrison

Board Regular
Joined
Dec 3, 2013
Messages
107
Office Version
  1. 365
  2. 2021
  3. 2019
Platform
  1. Windows
Right, Hello Guru's,

I have this code, and it alerts me when my Colleagues are 14 days or less away from their course.
The MsgBox asked them if they have booked transport. If the msgbox result clicks yes then i would like the code to no longer show that certain colleagues name again. If they click no, then leave it as each time the worksheet has been opened it'll pop up.

Code:
Private Sub Worksheet_Activate_Part2()   Dim LRow As Integer
   Dim LResponse As Integer
   Dim LLName As String
   Dim LFName As String
   Dim LTitle As String
   Dim LDiff As Integer
   Dim LDays As Integer
   LRow = 6
   'Warning - Number of days to check for expiration
   LDays = 14
   'Check the first 50 rows in column P
   While LRow < 30
      'Only check for expired certificate if value in column C is not blank
      If Len(Sheets("Colleagues").Range("P" & LRow).Value) > 0 Then
         LDiff = DateDiff("d", Date, Sheets("Colleagues").Range("P" & LRow).Value)
         If (LDiff > 0) And (LDiff <= LDays) Then
            'Get name
            LTitle = Sheets("Colleagues").Range("D" & LRow).Value
            LFName = Sheets("Colleagues").Range("E" & LRow).Value
            LLName = Sheets("Colleagues").Range("F" & LRow).Value
            LResponse = MsgBox(LTitle & " " & LFName & " " & LLName & " is attending thier course in, " & LDiff & " days." & Chr(13) & "" & Chr(13) & "Have you booked Transport?", vbCritical + vbYesNo, "Warning")
         End If
      End If
      LRow = LRow + 1
   Wend
End Sub

Any help would be much appreciated.

Kind regards,
Kyle
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Use a column to store LResponse. Check the value as needed.
Code:
If Not Sheets("Colleagues").Range("G" & LRow).Value = vbYes Then
  LResponse = MsgBox(LTitle & " " & LFName & " " & LLName & " is attending thier course in, " & LDiff & " days." & Chr(13) & "" & Chr(13) & "Have you booked Transport?", vbCritical + vbYesNo, "Warning")
  Sheets("Colleagues").Range("G" & LRow).Value = LResponse
End If
 
Upvote 0

Forum statistics

Threads
1,213,510
Messages
6,114,040
Members
448,543
Latest member
MartinLarkin

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