Adding today's date if certain conditions apply
I am trying to add the current date when a particular cell is used for data.
The date needs to populate in another cell, and remain unchanged as long as the other cell has data. How do I do it? I have tried an if-then statement using today(), but I obviously didn't write it correctly. Thanks! |
Adding today's date if certain conditions apply
Daniel,
the easy solution: =IF(A1<"",TODAY(),"") But this will leave the cell with a changing value, whenever you recalculate. The other solution is based on an event procedure. Here I am assuming A1 is the key cell and B1 is the one to be populated with the date at the moment of the change: Private Sub Worksheet_Change(ByVal Target As Range) If Not Intersect(Target, Range("A1")) Is Nothing Then If Range("A1") < "" Then Range("B1") = Date Else Range("B1") = "" End If End If To install: Right click on the sheet tab. Choose View Code... Paste the above code. HTH Kostis Vezerides On Jan 29, 8:51 pm, "Daniel Lapin" wrote: I am trying to add the current date when a particular cell is used for data. The date needs to populate in another cell, and remain unchanged as long as the other cell has data. How do I do it? I have tried an if-then statement using today(), but I obviously didn't write it correctly. Thanks! |
All times are GMT +1. The time now is 12:58 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com