Forum Discussion

CHollander's avatar
CHollander
Copper Contributor
Dec 08, 2022

limit the "NOW" function.

Is there a way (to have one cell on the top of a row) track the date that a change was made in that row? Or  is there  away to limit the "NOW" function to a few select cells? For example, =if( there ...
  • OliverScheurich's avatar
    OliverScheurich
    Dec 12, 2022

    CHollander 

    Private Sub Worksheet_Change(ByVal Target As Range)
    
    Dim rngBereich As Range
    Dim j As Long
    
    Application.EnableEvents = False
    
    Set rngBereich = Range("A2:XFD1048576")
    
    If Target.Cells.Count > 1 Then GoTo done
    
    If Not Application.Intersect(Target, rngBereich) Is Nothing Then
    
    If Target.Value <> "" Then
    j = Target.Column
    Cells(1, j).Value = Now
    Else
    
    End If
    
    End If
    
    done:
    Application.EnableEvents = True
    Exit Sub
    
    End Sub

    You can try this code. In the attached file you can enter data in any cell in range A2:XFD1048576. The code then determines the column of the target cell and enters the current day and time in row 1 of the target column.

Resources