Automatic data entry if a cell is changed

Private Sub Worksheet_Change(ByVal Target As Range)
Dim L

s = Application.Count(Range(“e:e”))
Application.EnableEvents = False
‘The next line checks to see if the cell being changed
‘is in the range we are interested in. Anywhere in Col E

If Not Intersect(Target, Range(“e:e”)) Is Nothing Then
newval = Cells(s, 5)
prevval = Cells(s – 1, 5)
i = Int(prevval / 100)
If Right(newval, 2) < Right(prevval, 2) Then i = i + 1
i = i * 100
Cells(s, 5) = i + newval
End If

‘Turn events back on
Application.EnableEvents = True
End Sub

Leave a Reply