VBA Time Stamp When Cell Changes.

alexfooty

Board Regular
Joined
Dec 30, 2018
Messages
97
Office Version
  1. 2016
Platform
  1. Windows
Quite simply, if the value in cell I13 in a worksheet changes I would like a date & time stamp to appear in cell M8 which updates every time cell I13 changes.
Many thanks and Merry Christmas to you all.
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
This should be in the corresponding worksheet module, not in any other module or in ThisWorkbook.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("I13")) Is Nothing Then ActiveSheet.Range("M8") = Format(Now, "d/m/yyyy HH:MM:SS")
End Sub
 
Upvote 0
Thanks eduzs but for some reason this is not working. The value in cell I13 is changed as a result of running a seperate macro but I wouldn't think that would have caused your macro to fail. I'm reuctant to upload an image unfortunately as the sheet is a personal medical worksheet. I'm at a loss as to why your macro doesn't work. Any ideas?
 
Upvote 0
Right click on the sheet tab - View code - and pasted it there
 
Upvote 0
If you call the sub from elsewhere, is better to specify the target worksheet:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim oSht As Worksheet
Set oSht = Sheets("targetworksheetname")
If Not Intersect(Target, oSht.Range("I13")) Is Nothing Then oSht.Range("M8") = "'" & Format(Now, "d/m/yyyy HH:MM:SS")
Set oSht = Nothing
End Sub
 
Upvote 0
Now getting a bit complicated for me... here is a cropped image of the area I'm working with...
Image 1.png

Cell G13 (Click=1 Use) runs a macro that increases cell I13 by "1". Each time cell I13 changes I need the time stamp to appear in cell M8. Unfortunately nothing is happening.
I am not technically minded so please bear in ming when answering. I just try to learn things in VBA as I go along.
 
Upvote 0
As Fluff said, why not use the first macro to add the cell stamp to the M8?
If you do not manually change the I13 value, I suppose that a separate macro is not required to do this.
Just insert at the end of the macro something like:
VBA Code:
oSht.Range("M8") = "'" & Format(Now, "d/m/yyyy HH:MM:SS")
Is there any "Application.EnableEvents = False" in your vba code?
 
Upvote 0
What is your existing macro?
 
Upvote 0

Forum statistics

Threads
1,215,061
Messages
6,122,921
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top