Excel Formula which places date/time in cell when data is entered in another cell in the same row

后端 未结 6 1833
一个人的身影
一个人的身影 2021-01-12 00:30

Hoping there is a way this can be done with a formula since I will be putting this on SharePoint as a shared workbook.

Column B contains Tasks, while Column E cont

6条回答
  •  礼貌的吻别
    2021-01-12 00:49

    This can be accomplished with a simple VBA function. Excel has support for a Worksheet Change Sub which can be programmed to put a date in a related column every time it fires.

    Private Sub Worksheet_Change(ByVal Target As Range)
        If Target.Column = 2 And Target.Offset(0, 3).Value = "" Then
            Target.Offset(0, 3) = Format(Now(), "HH:MM:SS")
        End If
    End Sub
    

    A quick explanation. The following "if" statement checks for two things: (1) if it is the second column that changed (Column B), and (2) if the cell 3 columns over (Column E) is currently empty.

    If Target.Column = 2 And Target.Offset(0, 3).Value = "" Then
    

    If both conditions are true, then it puts the date into the cell in Column E with the NOW() function.

    Target.Offset(0, 3) = Format(Now(), "HH:MM:SS")

    Range.Offset

    Range.Column

提交回复
热议问题