Macro Help: Change Timestamp When Worksheet Range Changed

ACF0303

New Member
Joined
Aug 29, 2013
Messages
41
Greetings,

I am trying to have one cell (G5) populate with a timestamp when a change is made to any cells in a range (some are merged). The code below worked for a second, until it didn't. Any help would be greatly appreciated.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("F8:G33")) Is Nothing Then Exit Sub
Range("G5").Value = Now()
End Sub

*Getting a yellow arrow by the row starting with Range("G5")

Thanks!
Cathy
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
I did password protect the sheet.......that's it isn't it? I've also noted that the timestamp does not match what is on my computer.....same problem? Do I need code to unlock/relock the sheet?
 
Upvote 0
Um....could you help me with that? I'm learning as I go along....no real VBA training.

Change the password to suit

Code:
[color=darkblue]Private[/color] [color=darkblue]Sub[/color] Worksheet_Change([color=darkblue]ByVal[/color] Target [color=darkblue]As[/color] Range)
    
    [color=darkblue]If[/color] Intersect(Target, Range("F8:G33")) [color=darkblue]Is[/color] [color=darkblue]Nothing[/color] [color=darkblue]Then[/color] [color=darkblue]Exit[/color] [color=darkblue]Sub[/color]
    
    Me.Unprotect Password:="secret"
    Range("G5").Value = Now
    Me.Protect Password:="secret"
    
[color=darkblue]End[/color] [color=darkblue]Sub[/color]

Tip: you can get example code by recording the steps (unprotect sheet\protect sheet) in a macro, and then copy the relevant bits to your final macro. I do it all the time.

Tip2: highlight a command in the code (e.g. Protect) and press the F1 key to get help on that command; syntax, definition, example code.
 
Upvote 0

Forum statistics

Threads
1,216,146
Messages
6,129,134
Members
449,488
Latest member
qh017

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