Colouring locked cells

W

WiLLerZ

I know this is probably a very basic question, but I just can't work it
out. How do you set cells to automatically turn a certain colour when
they are locked? I want my locked cells to be a light blue colour.
Thanks
 
J

Jon von der Heyden

Hi,

Place this code in a module:

Sub WillerZ()

Dim a as Range

For Each a in ActiveSheet.UsedRange

If a.Locked = True Then
a.Interior.ColorIndex = 20
End If

Next a

End Sub

This will only work on an unprotected worksheet.

Regards,
Jon von der Heyden
 
D

Dave Peterson

Another way if you're not using format|conditional formatting, you could select
the cells (all of them???) and with A1 the the activecell:

Format|conditional formatting
formula is: =cell("protect",a1)
Give it a nice format.
 
Top