Sorry to come back on this but I have a small issue with the slighly modified code.
I have validation setup on cells in column 6 such that I can only enter a number between 0 and 100. When I enter, say, 100.5 then I get a validation failed message but if I accidently press ESC key then I get error "1004 Application Defined or object defined" on the line;
Full code is below;Code:Target.Offset(, 1) = 0
Any idea how to trap / stop this error?Code:Private Sub Worksheet_Change(ByVal Target As range) If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub 'if multiple cells are selected then exit to avoid an error If Target.Column = 6 And Not Target = 0 Then 'if discount column has been updated and is not 0 then set price cell to 0 Target.Offset(, 1) = 0 Else If Target.Column = 7 And Not Target = 0 Then 'if price column has been updated and is not 0 then set discount cell to 0 Target.Offset(, -1) = 0 End If End If End Sub
Thanks




Reply With Quote