log date when the file is open

lezawang

Well-known Member
Joined
Mar 27, 2016
Messages
1,492
Hi

I want to log the date that a file is opened. For example, If I open the file today and I entered case#2 then the date should be today date in date column but if I open this file tomorrow for case#3 then tomorrow date should be in date column at the same time case #1 and 2 date should not change.

Is there any way I can do that?

Thank you so much

Case#Date -opened
115/10/2019
211/11/2013
3

<tbody>
</tbody>
 

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
17,975
Office Version
2013
Platform
Windows
Paste this in the sheet module of the sheet you are working with


Code:
Sub Worksheet_Change(ByVal Target As Range)
    If Target.Column = 1 Then
        If Target.Value <> "" Then
            Range("B" & Target.Row).Value = Date
        End If
    End If
End Sub
 
Last edited:

lezawang

Well-known Member
Joined
Mar 27, 2016
Messages
1,492
This is great. Thank you so much. It is really amazing. Could you please break it down, I mean if you can explain to me what is "Target".
Also you said to copy this code in the sheet I am working on, and I did, but my question, by doing that, does that mean this code
is running in the background of the sheet. Thank you so much for the help once again.
 

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
17,975
Office Version
2013
Platform
Windows
Target is the column that is being used to trigger the code in this case Column 1 or Column "A"
The code is only used by that sheet and isn't running until one of the "target" cells is used !!
 

Forum statistics

Threads
1,078,437
Messages
5,340,277
Members
399,361
Latest member
Linford

Some videos you may like

This Week's Hot Topics

  • Problem with Radio Button's format control
    I am creating an employee evaluation template (a sample is below) Column A is the category Column B, C D, E and F will be ratings (unacceptable...
  • Last Display on userform to a Listbox
    [CODE=vba] lstdisplay.ColumnCount = 15 lstdisplay.RowSource = "A1:O600000" [/CODE] So when i do this it Displays everything on the sheet i am...
  • Rename and move files to a new location
    Dear all, I have an excel file with the following information. The actual file name is at column A but i want to rename it using the following...
  • Help with True/False Formula
    Hello! Am stumped how to fix this formula, in which my result returns 'True', but it should return False. =IF(AG2=True...
  • Clear extra characters from a provided range of cells
    Dear All, I have following code which gives me desired output to remove extra characters from a provided range. But it takes too much time when...
  • Help with Current and highest streaks
    Hi there, I've just joined the forum and this is my first post. I've already spent quite a bit of time searching the net and this forum for a...
Top