How select unlocked cells only

  • Thread starter Thread starter Metallo
  • Start date Start date
M

Metallo

Hi,

I need to select the unlocked cells in an excel sheet that I have
protected.
The scope is to format those cells with a different colour to make
easier for the enduser to spot them.

I have found the following macro in the newsgroup:

Sub FindUnlocked()
Dim c As Range
Dim sel As String
Dim sel2 As String
For Each c In ActiveSheet.UsedRange
If c.Locked = False Then
sel = sel & "," & c.Address
End If
Next
sel2 = Right(sel, Len(sel) - 1)
Range(sel2).Select
End Sub

This is supposed to do the job but when I run it, I get the following
error:

Run-time error '1004':
Method 'range' of object'_Global' failed

Do you know what it means and how to solve it?
I use Excel 2000

Thank you
Alex
 
Hi
why not use something like
Sub FindUnlocked()
Dim c As Range
For Each c In ActiveSheet.UsedRange
If c.Locked = False Then
c.interior.colorindex=3
End If
Next
End Sub
 
Hi Alex,

As an alternative approach, you could use conditional formatting and set the
Formula Is condition to:

=CELL("protect",A1)
 
Hi,

Thank you guys for your solutions, I'm going to try both and see which one
will work best.

Cheers
Alex
 

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

Back
Top