Private Sub Worksheet_Change(ByVal Target As Range)
'Do nothing if more than one cell is changed or content deleted
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
Application.EnableEvents = False
col = Target.Column
Row = Target.Row
Parm = Cells(Row, 2)
If col = 2 Then
Range("C" & Row & ":N" & Row).ClearContents
End If
Select Case Parm
Case Is = "Work A"
If col = 2 Then
Cells(Row, 5).Activate
Else
If col = 5 Then
Cells(Row, 8).Activate
GoTo exitsub
Else
If col <> 8 Then
Cells(Row, col) = ""
GoTo exitsub
End If
End If
End If
Case Is = "Work B"
If col = 2 Then
Cells(Row, 6).Activate
Else
If col <> 6 Then
Cells(Row, col) = ""
GoTo exitsub
End If
End If
Case Is = "Work C"
If col = 2 Then
Cells(Row, 4).Activate
Else
If col = 4 Then
Cells(Row, 12).Activate
GoTo exitsub
Else
If col <> 12 Then
Cells(Row, col) = ""
GoTo exitsub
End If
End If
End If
Case Is = "Work D"
If col = 2 Then
Cells(Row, 14).Activate
Else
If col <> 14 Then
Cells(Row, col) = ""
GoTo exitsub
End If
End If
Case Is = "Work E"
If col = 2 Then
Cells(Row, 3).Activate
Else
If col = 3 Then
Cells(Row, 13).Activate
GoTo exitsub
Else
If col <> 13 Then
Cells(Row, col) = ""
GoTo exitsub
End If
End If
End If
Case Else
' Exit Sub
End Select
'Stop any possible runtime errors and halting code
On Error Resume Next
exitsub:
'Turn events back on
Application.EnableEvents = True
'Allow run time errors again
On Error GoTo 0
End Sub
Try this:
It clears previous entries if a line has already been entered i.e. is being overwritten
To insert code, right click on Sheet1, View code: you can then copy and paste into your master file by repeating the "view code" on sheet in master file.
Bookmarks