I have a column where I want to set a default value for every cell of 0.00. I want the user to be able to enter a value in any cell, but if the user changes their mind and deletes a value from any cell, the value in that cell should default back to 0.00 rather than appear blank.
I came across this code, which almost works, but I'm unsure how to adapt it so that it will apply to any cell where the user deletes a value, rather than just the first cell (A2). My VBA is limited but I'm sure it is probably an easy tweak, I'm just not sure how to do it? At the moment any deleted values (see attached) will only be restored to the default 0.00 if the value in cell A2 is deleted, but it needs to work for all cells.
Many thanks
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A2:A18")) Is Nothing Then
If Range("A2").Value = "" Then
Range("A2:A18").Value = 0#
End If
End If
End Sub
Bookmarks