Code giving run-time error when called, but not when placed on worksheet.

FrancisM

Board Regular
Joined
Apr 12, 2016
Messages
139
The code listed below runs on the worksheet, but gives a Run-time error '424': Object required when called. I called the code, because when placed on the worksheet, it prevented other code from running. I was thinking that if the code was called it would allow the other code to run.

VBA Code:
Sub Do_Carryover()

'Reminds the user to enter the carryover name into the current FY listing.
Dim MsgBoxResult As Long
If Target.Count > 1 Then Exit Sub
If Intersect(Target, Range("B4:B17")) Is Nothing Then Exit Sub
       MsgBoxResult = MsgBox("Is the Veteran a a new client to Career Link? " & vbCr, _
       vbYesNo, "Vocational Services - OVR " & ActiveSheet.Name)
       If MsgBoxResult = vbNo Then
     
       MsgBox " Check to verify Veteran data is entered in FY ##  Referrals! " & vbCr & _
                   "" & vbCr & _
                   " It's critical that Veteran data is captured. " & vbCr & _
                   "" & vbCr & _
                   " Please enter the name in walk in list if not on this year's consult list! " & vbCr & _
                   "Do not enter the name on the Walk In list of there is a Consult for this FY! " & vbCr & _
                   "" & vbCr & _
                   " Enter veteran as a walk in, if a carry over from the past FY year, and enter the SC percent! " & vbCr & _
                   "" & vbCr & _
                   " You have entered " & Cells(Target.Row, 2) & " in cell " & Target.Address, vbInformation, "Vocational Services - Career Link" & ActiveSheet.Name
           
                Call Referals 'Calls Referrals folder.
               
       ElseIf MsgBoxResult = vbYes Then
            If WorksheetFunction.CountA(Range("B:B")) <> 0 Then
            MsgBox " Check to verify Veteran data is entered in FY ##  Referrals! " & vbCr & _
                   "" & vbCr & _
                   " It's critical that Veteran data is captured. " & vbCr & _
                   "" & vbCr & _
                   " Please enter the name in walk in list if not on this year's consult list! " & vbCr & _
                   "Do not enter the name on the Walk In list of there is a Consult for this FY! " & vbCr & _
                   "" & vbCr & _
                   " Enter veteran as a walk in, if a carry over from the past FY year, and enter the SC percent! " & vbCr & _
                   "" & vbCr & _
                   " You have entered " & Cells(Target.Row, 2) & " in cell " & Target.Address, vbInformation, "Vocational Services - Career Link" & ActiveSheet.Name
           
                Call Referals 'Calls Referrals folder.
            Else
                Exit Sub
                End If
                End If
End Sub

Please tell me what I am doing wrong. Will calling the code allow the other code to run?
 
Glad we all could help and thanks for all the mentions - its very much appreciated.

Dave
 
Upvote 0

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Now I will test the other problem lines & see if they are still a problem
If you are referring to the Change Event, possibly not due to this
Rich (BB code):
Call Do_Carryover
      
    'This section of code provides notification if there is a scheduling conflict.
    If Target.Count > 1 Then Exit Sub
    If Not Intersect(Target, Range("H5:H10, H13:H17")) Is Nothing Then
 
Upvote 0
If you are referring to the Change Event, possibly not due to this
Rich (BB code):
Call Do_Carryover
     
    'This section of code provides notification if there is a scheduling conflict.
    If Target.Count > 1 Then Exit Sub
    If Not Intersect(Target, Range("H5:H10, H13:H17")) Is Nothing Then
I still am having issues with the other code. However I will post the problems as a separate posts since this one solved the initial post question.
 
Upvote 0
Ok, that's fine & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,170
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