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

KyleJackMorrison

Board Regular
Joined
Dec 3, 2013
Messages
90
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
 

Kenneth Hobson

Well-known Member
Joined
Feb 6, 2007
Messages
3,092
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
 

Forum statistics

Threads
1,081,545
Messages
5,359,450
Members
400,528
Latest member
Ratish52

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top