Preventing Call codes from running multiple times.

FrancisM

Board Regular
Joined
Apr 12, 2016
Messages
139
I have code that fluff was kind enough to help me with. It works as written, but when I added a call code, it would provide the following message multiple times "Check to verify veteran data is entered in FY ## REFERALS." "It's critical that the veteran data is captured." It didoes not matter if Yes or No is checked. the the response is the same. It then runs the call command the same number of times. I have tried moving moving the location of the call code, but the response is the same. Here is the code.

Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)

    Select Case Sh.CodeName
    'These are the worksheets here that are not to be called with change
         Case "Sheet1", "Sheet11", "Sheet21", "Sheet31", "Sheet41", "Sheet42", "Sheet43", "Sheet44", "Sheet 45", "Sheet46", "Sheet47", "Sheet48", "Sheet49", "Sheet50", "Sheet51", "Sheet52", "Sheet53", "Sheet54", "Sheet55", "Sheet56", "Sheet57", "Sheet82"
         
             Exit Sub
     End Select
     
     
     If Not (Application.Intersect(Target, Sh.Range("B4:B10, B13:B17")) _
       Is Nothing) Then   'Note that Range is now identified with the calling Sheet object variable (Sh)
         With Target
             If Not .HasFormula Then
                 Application.EnableEvents = False
                 .Value = UCase(.Value)
                 Application.EnableEvents = True
             End If
         End With
     End If
     'The code below is a reminder to enter data in the Referral Workbook.
     Application.ScreenUpdating = False
     Dim lastRow As Long
     Dim cell As Range
     lastRow = Range("G" & Rows.Count).End(xlUp).Row




   For Each cell In Range("H4:H10, H13:H17")
      If LCase(cell.Value) = "no" Then
         If Target.Value = "No" And Target.Offset(, 15).Value = True Then
            MsgBox "Check to verify veteran data is entered in FY ## REFERALS." & vbCr & _
                "It's critical that the veteran data is captured." & vbCr & _
                 "You have entered No into cell" & Target.Address, vbInformation, "Career Link Meeting List"
                
         End If
      End If
   Next
 'Call Referals
Application.ScreenUpdating = True


 End Sub
The piece of code that causing a problem is Call Referals​.
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
I have just learned that the number of times the message appears & the call code is related the the number of times there is a "No" in Column H & TRUE in Column W. I am trying to get it to run only once. I have Googled, but have not found anything like this. I will keep looking.
 
Upvote 0
If you are writing anything to the workbok in your call code it will automatically retrigger the worksheet change event software so you will get multiple responses. This could be the cause of the problem. To avoid this you must wrap
Code:
Application.EnableEvents = False
'' your code
Application.EnableEvents = True
around the cdoe that writes to the workbook
 
Upvote 0
That code I found, just before your message. I found that it is still running the same way. I am thinking, possibly interrupting the code.
 
Upvote 0
Try adding this
Code:
[COLOR=#ff0000]Dim Chk As Boolean[/COLOR]
For Each cell In Range("H4:H10, H13:H17")
   If Target.Value = "No" And Target.Offset(, 15).Value = True Then
      MsgBox "Check to verify veteran data is entered in FY ## REFERALS." & vbCr & _
          "It's critical that the veteran data is captured." & vbCr & _
           "You have entered No into cell" & Target.Address, vbInformation, "Career Link Meeting List"
      [COLOR=#ff0000]Chk = True
      Exit For[/COLOR]
   End If
Next
[COLOR=#ff0000]If Chk Then Call Referals[/COLOR]
 
Upvote 0
That's because the code you are running & the code you posted are not the same.
Try using the code you posted along with the mods in post#6
 
Upvote 0
The code in that file looks to be exactly the same as the last one & is not the same as the code you posted here, which makes it nigh on impossible for us to help you.
Change the code in your workbook to what you posted here, along the changes I showed.
 
Upvote 0

Forum statistics

Threads
1,224,822
Messages
6,181,165
Members
453,021
Latest member
Justyna P

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