Question : Excel Date column - autopopulate with today's date or incrementing date (part 2)

See the related question. jppinto got me started. I have a solution that is "good enough" but the date value for the column is a formula, and if I change one value, the dependant rows cascade changes. I don't want that.

If possible, I want to simply insert a row everyday, and have COL A populate with the date, as data, not formula.

Thanks,

-mjc

Answer : Excel Date column - autopopulate with today's date or incrementing date (part 2)

mjc,

If you add this code to the Sheet module for the worksheet you need "watched", it should do the trick.  Basically,
every time you edit a cell in Col B, Col A gets the current system date.

Private Sub Worksheet_Change(ByVal Target As Range)
   
    Dim MaxRows As Long
    Dim cel As Range
   
    MaxRows = Me.Rows.Count
   
    If Not Intersect(Me.Range("b2:b" & MaxRows), Target) Is Nothing Then
        Application.EnableEvents = False
        For Each cel In Intersect(Me.Range("b2:b" & MaxRows), Target).Cells
            If cel <> "" Then
                Cells(cel.Row, "a") = Date
            Else
                Cells(cel.Row, "a").ClearContents
            End If
        Next
        Application.EnableEvents = True
    End If
   
End Sub



Patrick
Random Solutions  
 
programming4us programming4us