kiwikiki718
Board Regular
- Joined
- Apr 7, 2017
- Messages
- 80
- Office Version
- 365
- Platform
- Windows
Hi I have 2 worksheet_change events that I am trying to run on worksheet 1 but I keep receiving a error stating "ambiguous name detected: worksheet_change".. please help. see below code
Private Sub worksheet_change(ByVal Target As Range)
If Target.CountLarge > 1 Then Exit Sub
If Intersect(Target, Range("A3,A13,A23,A33,A43,A53,A63,A87,A97,A107,A117,A127,A137,A147,B3,B13,B23,B33,B43,B53,B63,B87,B97,B107,B117,B127,B137,B147")) Is Nothing Then Exit Sub
If Target = "" Then Target = 0
Application.ScreenUpdating = False
End Sub
Private Sub worksheet_change(ByVal Target As Range)
If Application.CountIf(Range("J3:J12"), Target) > 1 Then
MsgBox "Duplicate Selection!", vbCritical, "Remove Data"
Target.Value = ""
End If
If Application.CountIf(Range("J13:J22"), Target) > 1 Then
MsgBox "Duplicate Selection!", vbCritical, "Remove Data"
Target.Value = ""
End If
If Application.CountIf(Range("J23:J32"), Target) > 1 Then
MsgBox "Duplicate Selection!", vbCritical, "Remove Data"
Target.Value = ""
End If
If Application.CountIf(Range("J33:J42"), Target) > 1 Then
MsgBox "Duplicate Selection!", vbCritical, "Remove Data"
Target.Value = ""
End If
If Application.CountIf(Range("J43:J52"), Target) > 1 Then
MsgBox "Duplicate Selection!", vbCritical, "Remove Data"
Target.Value = ""
End If
If Application.CountIf(Range("J53:J62"), Target) > 1 Then
MsgBox "Duplicate Selection!", vbCritical, "Remove Data"
Target.Value = ""
End If
If Application.CountIf(Range("J63:J72"), Target) > 1 Then
MsgBox "Duplicate Selection!", vbCritical, "Remove Data"
Target.Value = ""
End If
If Application.CountIf(Range("J87:J96"), Target) > 1 Then
MsgBox "Duplicate Selection!", vbCritical, "Remove Data"
Target.Value = ""
End If
If Application.CountIf(Range("J97:J106"), Target) > 1 Then
MsgBox "Duplicate Selection!", vbCritical, "Remove Data"
Target.Value = ""
End If
If Application.CountIf(Range("J107:J116"), Target) > 1 Then
MsgBox "Duplicate Selection!", vbCritical, "Remove Data"
Target.Value = ""
End If
If Application.CountIf(Range("J117:J126"), Target) > 1 Then
MsgBox "Duplicate Selection!", vbCritical, "Remove Data"
Target.Value = ""
End If
If Application.CountIf(Range("J127:J136"), Target) > 1 Then
MsgBox "Duplicate Selection!", vbCritical, "Remove Data"
Target.Value = ""
End If
If Application.CountIf(Range("J137:J146"), Target) > 1 Then
MsgBox "Duplicate Selection!", vbCritical, "Remove Data"
Target.Value = ""
End If
If Application.CountIf(Range("J147:J156"), Target) > 1 Then
MsgBox "Duplicate Selection!", vbCritical, "Remove Data"
Target.Value = ""
End If
End Sub
Private Sub worksheet_change(ByVal Target As Range)
If Target.CountLarge > 1 Then Exit Sub
If Intersect(Target, Range("A3,A13,A23,A33,A43,A53,A63,A87,A97,A107,A117,A127,A137,A147,B3,B13,B23,B33,B43,B53,B63,B87,B97,B107,B117,B127,B137,B147")) Is Nothing Then Exit Sub
If Target = "" Then Target = 0
Application.ScreenUpdating = False
End Sub
Private Sub worksheet_change(ByVal Target As Range)
If Application.CountIf(Range("J3:J12"), Target) > 1 Then
MsgBox "Duplicate Selection!", vbCritical, "Remove Data"
Target.Value = ""
End If
If Application.CountIf(Range("J13:J22"), Target) > 1 Then
MsgBox "Duplicate Selection!", vbCritical, "Remove Data"
Target.Value = ""
End If
If Application.CountIf(Range("J23:J32"), Target) > 1 Then
MsgBox "Duplicate Selection!", vbCritical, "Remove Data"
Target.Value = ""
End If
If Application.CountIf(Range("J33:J42"), Target) > 1 Then
MsgBox "Duplicate Selection!", vbCritical, "Remove Data"
Target.Value = ""
End If
If Application.CountIf(Range("J43:J52"), Target) > 1 Then
MsgBox "Duplicate Selection!", vbCritical, "Remove Data"
Target.Value = ""
End If
If Application.CountIf(Range("J53:J62"), Target) > 1 Then
MsgBox "Duplicate Selection!", vbCritical, "Remove Data"
Target.Value = ""
End If
If Application.CountIf(Range("J63:J72"), Target) > 1 Then
MsgBox "Duplicate Selection!", vbCritical, "Remove Data"
Target.Value = ""
End If
If Application.CountIf(Range("J87:J96"), Target) > 1 Then
MsgBox "Duplicate Selection!", vbCritical, "Remove Data"
Target.Value = ""
End If
If Application.CountIf(Range("J97:J106"), Target) > 1 Then
MsgBox "Duplicate Selection!", vbCritical, "Remove Data"
Target.Value = ""
End If
If Application.CountIf(Range("J107:J116"), Target) > 1 Then
MsgBox "Duplicate Selection!", vbCritical, "Remove Data"
Target.Value = ""
End If
If Application.CountIf(Range("J117:J126"), Target) > 1 Then
MsgBox "Duplicate Selection!", vbCritical, "Remove Data"
Target.Value = ""
End If
If Application.CountIf(Range("J127:J136"), Target) > 1 Then
MsgBox "Duplicate Selection!", vbCritical, "Remove Data"
Target.Value = ""
End If
If Application.CountIf(Range("J137:J146"), Target) > 1 Then
MsgBox "Duplicate Selection!", vbCritical, "Remove Data"
Target.Value = ""
End If
If Application.CountIf(Range("J147:J156"), Target) > 1 Then
MsgBox "Duplicate Selection!", vbCritical, "Remove Data"
Target.Value = ""
End If
End Sub