日期更改时的增量号 [英] Increment number when Date changes

查看:134
本文介绍了日期更改时的增量号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

美好的一天,

我有一个小问题。我有两个单元格:

I have a small problem. I have two cells:

B35是具有mmm-yy

的日期单元格B37是不带小数位数的数字。

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

我想要一个公式,当日期更改时,将B37增加1,即
B35:Mar-13
B37:4
当B35在4月13日输入,B37会自动更改为5。

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.

推荐答案

我想我已经弄清楚了。

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

谢谢

这篇关于日期更改时的增量号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆