Updating dates.

  • Thread starter Thread starter Marc Cappelle
  • Start date Start date
M

Marc Cappelle

Hello, is there somebody who can help me with the
following problem.

I work with Excel 97.
I have a date in one cell, and a number in another.
I want the date to change automatically to the current
date every time the number changes, but only then.
If the number doesn't change, the date has to remain the
same, even the next day.

regards,

Marc
 
Marc,

A simple worksheet event code can do this.

Private Sub Worksheet_Change(ByVal Target As Range)

Application.EnableEvents = False
On Error GoTo ws_exit
If Target.Address = "$G$1" Then
Range("F1").Value = Format(Date, "dd mmm yyyy")
End If
ws_exit:
Application.EnableEvents = True
End Sub

This goes in the worksheet code module of the relevant sheet.
 
Bob,

it works great.

Thank you very much.
-----Original Message-----
Marc,

A simple worksheet event code can do this.

Private Sub Worksheet_Change(ByVal Target As Range)

Application.EnableEvents = False
On Error GoTo ws_exit
If Target.Address = "$G$1" Then
Range("F1").Value = Format(Date, "dd mmm yyyy")
End If
ws_exit:
Application.EnableEvents = True
End Sub

This goes in the worksheet code module of the relevant sheet.

--
HTH

-------

Bob Phillips
... looking out across Poole Harbour to the Purbecks





.
 
Back
Top