Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
With Target
If .Count = 1 Then
If Cells(.Row, 1).Value = 0 Then
Cells(.Row, 1).Value = Application.Max(Range("A:A")) + 1
End If
End If
End With
Application.EnableEvents = True
End Sub