Timestamp For Specific Sheet

CokeOrCrack

Board Regular
Joined
Dec 13, 2015
Messages
81
- I have a workbook that contains 10 sheets
- I would like a timestamp to appear in cell G10 for when any edit is made in one specific sheet
i.e. The specific sheet is named "General", so I'd like the timestamp to appear in G10 in "General"
- I don't want the timestamp to change if edits are made in any of the remaining 9 sheets

Q
How do I timestamp any edit to a specific sheet?

I have tried the following code, and it occasionally works, but it will eventually return this error:

"Run-time error '-2147417848 (80010108)':
Method 'Range' of object'_Worksheet' failed"

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Sheets("General").Range("G10") = Now
End Sub

I don't understand why it initially works, but then returns the error.
Is this the best route to pursue for this question, or is there a better way?

Thanks

OJ
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Is the above code placed in the sheet module only for the General sheet?

The code is going to keep triggering itself and loop through everytime it edits the timestamp so you need something like:

Pasted in the sheet module only for "General"
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("G10")) Is Nothing Then Range("G10") = Now
End Sub
 
Upvote 0
Is there a way to attach an And statement into the If? I would like to put the user's name in cell K10 when an edit is made. The user's name is stored in a sheet titled "Numbers" in cell BC2
 
Upvote 0
Nevermind, I solved my own question. The following code will input both:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("G10:K10")) Is Nothing Then
        Range("G10:J10") = Now
        Range("K10") = Sheets("Numbers").Range("BC2")
        Cancel = True
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,953
Messages
6,175,598
Members
452,658
Latest member
GStorm

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