Increment number when Date changes

2019-09-14 22:10发布

Good day,

I have a small problem. I have two cells:

B35 is a date cell with mmm-yy and B37 is a number with no decimal places.

I would like a formula that increments B37 by 1 when ever the date changes, i.e B35: Mar-13 B37: 4 when B35 is inputted as Apr-13, then B37 changes to 5 automatically.

I hope I was able to put my problem through clearly. Thank You.

1条回答
成全新的幸福
2楼-- · 2019-09-14 22:11

I think I have figured it out.

Private Sub Worksheet_Change(ByVal Target As Range)
   If Not Intersect(Target, Range("B35")) Is Nothing Then
      Application.EnableEvents = False
      Range("B37").Value = Range("B37").Value + 1
      Application.EnableEvents = True
   End If
End Sub

Thank You

查看更多
登录 后发表回答