Discussion Locked

Maintain a write protect if copy a WB

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi,
Do you have a VBA code or another way that will help me to keep the cells in a worksheet write protected, even after copying it to another worksheet using copy/cut and paste.
Thanks

4 replies

by bishopca

I think you are asking how to save steps when you copy and paste cells. If that is the case, you should be able to develop a macro to do that.

It would probably look something like this:

Sub CopyProtect()
'Save Name of Worksheet
DimVarSH
VarSH = ActiveSheet.Name
'Unprotect the existing sheet
ActiveSheet.Unprotect
'Copy the area that user already selected
Selection.Copy
'Add a new sheet
Sheets.Add
'Use ActiveWorkbook.Worksheets("WorksheetName").paste If you do not want a new one
ActiveSheet.Paste
Selection.Locked = True
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
'Restore Protection to original worksheet
ActiveWorkbook.Worksheets(VarSH).Protect
End Sub

Without knowing more specifics about what you want I am afraid that I can only get you started toward the answer - GOOD LUCK!

This discussion is closed to new replies.