View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Overview over lockd cells in a sheet.

Hi Ebbe,

Try:

'=============
Public Sub ToggleLockedCellsColor()
Dim rCell As Range
Dim iColor As Long
Dim bNoColor As Boolean
Dim bLocked As Boolean
Dim res As String

res = InputBox("Enter the sheet protection password")

iColor = 6 '<<==== Yellow - Change to taste
bLocked = False

On Error Resume Next
ActiveSheet.Unprotect res
If Err.Number < 0 Then
MsgBox "Password not recognised"
Exit Sub
End If

For Each rCell In ActiveSheet.UsedRange.Cells
With rCell
If .Locked Then
bNoColor = rCell.Interior.ColorIndex = xlNone
bLocked = True
Exit For
End If
End With
Next rCell

If Not bLocked Then
MsgBox Prompt:="No locked cells found!", _
Buttons:=vbInformation, _
Title:="Locked Cells"
End If

For Each rCell In ActiveSheet.UsedRange.Cells
With rCell
If .Locked Then
.Interior.ColorIndex = IIf(bNoColor, iColor, xlNone)
End If
End With
Next

ActiveSheet.Protect res

End Sub
'<<=============


---
Regards,
Norman


"Ebbe" wrote in message
...
Hi

I am working with a sheet in witch som registration is entered and then
some formels ar calculating on the entered data.

My concern is that I have unprotected cells, that should be protected and
protected cells, that should be unprotected

Is it possible to highligt all protected/unprotected cells in a sheet?
The formel control function varns me if a cell with a formel is not
protected (locked).
But blank cells and cells with prompt text can be unprotected without
varnings.

Ebbe