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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top