some 'Protection' questions
Bri
Paul has addressed a)
b) unprotect the sheet, run your code then re-protect.
Sub SHEETUNPROTECT()
ActiveSheet.Unprotect Password:="justme"
'your code goes here
ActiveSheet.Protect Password:="justme"
End Sub
c)To highlight all locked cells....................
Sub Locked_Cells()
Dim cell As Range, tempR As Range, rangeToCheck As Range
'check each cell in the selection
For Each cell In Intersect(Selection, ActiveSheet.UsedRange)
If cell.Locked Then
If tempR Is Nothing Then
'initialize tempR with the first qualifying cell
Set tempR = cell
Else
'add additional cells to tempR
Set tempR = Union(tempR, cell)
End If
End If
Next cell
'display message and stop if no cells found
If tempR Is Nothing Then
MsgBox "There are no Locked cells " & _
"in the selected range."
End
End If
'select qualifying cells
tempR.Interior.ColorIndex = 3
End Sub
d) No way to prevent deletion of a file unless you have exclusive permissions
for the folder in which the file is stored.
See Windows Help and Support for "permissions". Be very careful with
this.........you could lock yourselef out.
Gord Dibben MS Excel MVP
On Tue, 24 Jan 2006 16:49:17 -0500, "Bri" wrote:
Hello
I have a workbook nearing completion and I'm now adding (well, attempting)
protection. I have some questions:
a) Each worksheet has regions of unlocked cells, the others being locked.
I can protect each work sheet one-by-one. Is there a way to protect them
all at once? (Selecting all tabs leaves ToolsProtectionProtect Sheet ...
grayed out.)
b) My worksheets contain macros that either hide or show columns using Subs
with code fragments like 'Columns(N).Hidden = False'. When a worksheet is
protected with the default 'select locked cells' and 'select unlocked
cells' checked, I can't run the macros. If I also check the 'format
columns' protection option, the macros work properly, but the user can alter
column widths (undesirable). Is there an easy solution?
c) I have many worksheets with several regions either locked or unlocked.
Is there an easy way to show the locked status of each cell without having
to check each one individually?
d) I think this one is really dumb, but here goes. I took a test excel
file and fully protected each sheet and the entire workbook (both structure
and windows). As expected, I couldn't really do anything after that, but I
could go into explorer and erase the entire file. Is this easily
preventable?
Much thanks
Bri
|