Change in worksheet create an error in compile

dade652003

New Member
Joined
Apr 23, 2013
Messages
34
I have excel 2010 and so do my employee's.

For some reason some employees does not work and gives them a complile error to debug.

The code is the following:

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

If Not Intersect(Target, [C:C]) Is Nothing And Target.Cells.Count = 1 Then
If Target.Value = "Employee" Then
Target.Offset(0, 4).Value = InputBox("Please enter the Employee's name!, Please enter name or cancel to continue")
    End If
End If
If Not Intersect(Target, [D:D]) Is Nothing And Target.Cells.Count = 1 Then
If Target.Value = "Payment" Then
Target.Offset(0, 5).Value = InputBox("Please enter $$ Amount, Please enter payment or cancel to continue")
    End If
End If
If Not Intersect(Target, [A:A]) Is Nothing And Target.Cells.Count = 1 Then
If Target.Value Then
Target.Offset(0, 1).Value = InputBox("Please enter Phone#...Incase we are disconnected, Please enter phone # or cancel to continue")
    End If
End If
If Not Intersect(Target, [B:B]) Is Nothing And Target.Cells.Count = 1 Then
If Target.Value Then
Target.Offset(0, 5).Value = InputBox("Please enter Name...Good Customer Service, Please enter phone # or cancel to continue")
    End If
End If

End Sub

Could anyone point me to the right direction as why some of my employees there is no problem and others it debugs. On my excel is runs perfectly with no bugs.
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
here is your code slightly cleaned up

two lines will fail if value is entered into cells in column A and B because a boolean value (true/false) is expected

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


    If Target.Cells.Count <> 1 Then Exit Sub


    If Not Intersect(Target, [C:C]) Is Nothing Then     ' cell changed in column C
        If Target.Value = "Employee" Then
            Target.Offset(0, 4).Value = InputBox("Please enter the Employee's name!, Please enter name or cancel to continue")
        End If
    End If
        
    If Not Intersect(Target, [D:D]) Is Nothing Then     ' cell changed in column D
        If Target.Value = "Payment" Then
            Target.Offset(0, 5).Value = InputBox("Please enter $$ Amount, Please enter payment or cancel to continue")
        End If
    End If
        
    If Not Intersect(Target, [A:A]) Is Nothing Then     ' cell changed in column A
[COLOR=#ff0000]        If Target.Value Then[/COLOR]
            Target.Offset(0, 1).Value = InputBox("Please enter Phone#...Incase we are disconnected, Please enter phone # or cancel to continue")
        End If
    End If
        
    If Not Intersect(Target, [B:B]) Is Nothing Then     ' cell changed in column B
[COLOR=#ff0000]        If Target.Value Then[/COLOR]
            Target.Offset(0, 5).Value = InputBox("Please enter Name...Good Customer Service, Please enter phone # or cancel to continue")
        End If
     End If


End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,213,558
Messages
6,114,296
Members
448,564
Latest member
ED38

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