Background - Excel

N

NewTOVBA

Is the a way to write a VBA prgram that goes through every cell in a
range (Named "TextRange" ) and determine if the cell is locked or not
locked. If it is locked change the background to one color and of not
change it to a different color

Perhaps there is a setting in Excel that does it automatically?
 
G

Gary''s Student

Try:

Sub locktest()
For Each r In Range("TextRange")
If r.Locked = True Then
r.Interior.ColorIndex = 6
Else
r.Interior.ColorIndex = 3
End If
Next

This will color locked cells yellow and the others red.
 
Top