Forum Discussion
IF Statement Concerns
- Apr 24, 2018
Hello,
what you want to achieve cannot be done with the NOW() formula. It will always update to the current date and time. If you want a time stamp that does not change, then you will need to use VBA.
This code will put a time stamp into column B when a cell in column A is changed by the user. Copy the code, then right-click the Sheet, select "View code" and paste the code into the code window.
Private Sub Worksheet_Change(ByVal Target As Range) If Not Intersect(Target, Range("A:A")) Is Nothing Then Target.Offset(0, 1) = Now End If End Sub
Thank you IngeborgHawighorst . This little piece of code solved a perplexing problem for me. A next step is to save the workbook as a macro-enabled workbook (.xlsm). I did not do that and when I reopened the file, code was gone. Luckily I found it again, along with a post with the save info. I backed up the code to a text file for safe keeping.
PCDavis61618 When you write VBA code in Excel that does not yet have any code, and then save the file, you will see a big, fat warning that VBA code can only be saved in macro-enabled files and you are prompted to save the file as a macro-enabled file. If you just ignore that warning, your code will be lost, of course.
Excel has done its part. Now it's up to you to do yours.