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

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
The code in all three files is NOT the same as the code you supplied in Post#1.
Therefore the changes I suggested will not work.
Please delete the change event you are using & replace it with the code from post#1 along with the changes I suggested.
Do NOT simply upload another copy of you workbook, but try what I have now suggested 3 times.
 
Upvote 0
The patch you provided does work. Thank for providing that & dealing with a person that wasn't seeing what was wrong with the other postings.
Here is the code so others my benefit from it.
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
   Dim Chk As Boolean
   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"
             Chk = True
             Exit For
                End If
      End If
   Next
 If Chk Then Call Referals
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Glad you figured it out & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,254
Members
452,624
Latest member
gregg777

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