incrementation of a value depending on another value

  • Thread starter Thread starter const gere
  • Start date Start date
C

const gere

Is there a solution to increment a value in a cell
everytime I introduce another value in another cell. For
instance in A1 i intriduce a srting and I want that in A2
the result will be the incremetation of a value, let'say
one(1), then if I introduce the same srting in A1 the
value in A2 will be two(2) and so on..
Thanks for your time and effort ..I realy appreciated.
 
You can use an event macro to do this. Right click on the worksheet tab that
should have this behavior. Then click View Code.

Paste this in:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

If Intersect(Target, Range("a1")) Is Nothing Then Exit Sub
If Target.Cells.Count > 1 Then Exit Sub

On Error GoTo errHandler:

With Target.Offset(1, 0) 'down a row
If IsNumeric(.Value) Then
Application.EnableEvents = False
.Value = .Value + 1
End If
End With

errHandler:
Application.EnableEvents = True

End Sub
 
Back
Top