Is there a way to auto date stamp anytime cells are edited in a protected sheet?

tobink

New Member
Joined
Nov 21, 2012
Messages
8
Hello,

I created a spreadsheet that needs to allow multiple users to add, edit, delete data in ceratin cells, but not be able to change the formatting. In order to accomplish this, I unlocked the cells that can be manipulated, then protected each sheet. Now, however, the auto date macro is not working and keeps popping up a debug option. Is there a way to have this macro run in a protected sheet? Here is the code I have (it works when not protected):

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A4:W155")) Is Nothing Then Exit Sub
Application.EnableEvents = False
Range("A1").Value = Now
Application.EnableEvents = True
End Sub

Thanks for the help!
 
Just realized after working in the spreadsheet a few minutes, that without the password added when I protect the sheet, I can't insert/delete rows or sort?? In the formatting for the unlocked cells, i have the boxes checked for insert row, delete row, sort...but it doesn't work with it protected. Sooo frustrating!
I don't think it's whether the password applied or not that affects what you can do, nor is it the format of unlocked cells, more it's the choices you apply in the Protect Sheet dialogue box when you're protecting the sheet.
If you record yourself a macro of you protecting the sheet the way you want with the options you want you'll end up with a variation of the following line:
Code:
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, AllowInsertingColumns:=True, AllowInsertingRows:=True, AllowFiltering:=True
Now you need to tweak that line for use in the worksheet_change event handler above to a bit like:
Code:
[COLOR=#ff0000]Me[/COLOR].Protect [COLOR=#ff0000]Password:="verysecretpassword"[/COLOR], DrawingObjects:=True, Contents:=True, Scenarios:=True, AllowInsertingColumns:=True, AllowInsertingRows:=True, AllowFiltering:=True, [COLOR=#ff0000]userinterfaceonly:=True[/COLOR]
And obviously, adjust the password before you run the code.
This line will execute whether the sheet is already protected or not.
 
Upvote 0

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Forum statistics

Threads
1,221,444
Messages
6,159,914
Members
451,603
Latest member
SWahl

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