Excel OnChange event

后端 未结 5 1012
清酒与你
清酒与你 2020-12-21 17:23

I want to update a cell with the date-time when a value is entered to another one so,

How can i change the value of the B column to the date-time when a value is e

5条回答
  •  执笔经年
    2020-12-21 17:47

    You could have tried this by yourself, couldn't you?
    In my opinion, the hardest part was to think about the Change event.

    Private Sub Worksheet_Change(ByVal Target As Range)    
    If Intersect(Target, Range("A:A")) Is Nothing Then Exit Sub
    Application.EnableEvents = False
    
    ActiveSheet.Cells(Target.Row, 2).Value = Format(Now, "h:mm")
    Application.EnableEvents = True
    End Sub
    

    You can change the Format content to whatever you need.

提交回复
热议问题