View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Stuart[_5_] Stuart[_5_] is offline
external usenet poster
 
Posts: 413
Default Code to colour Unlocked cells

Many thanks but it would appear not for me!
Using Excel 2000 and Win2k.

I get this error on the line:
Application.FindFormat.Locked = False

Run time error 438
Object doesn't support this property or method

I had begun to wonder if I could use the statement
.EnableSelection = xlUnlockedCells
in some way, since this seems to indicate a way to
'globally' identify the unlocked cells, rather than a
cell by cell approach.

Regards.

"Dana DeLouis" wrote in message
...
Don't know if this would help, but in later versions of Excel, the

following
appears to work... without a loop.

Sub Demo()
Application.FindFormat.Locked = False
Application.ReplaceFormat.Interior.ColorIndex = 4
Columns("A:G").Replace _
What:=vbNullString, _
Replacement:=vbNullString, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
MatchCase:=False, _
SearchFormat:=True, _
ReplaceFormat:=True

End Sub

HTH :)
Dana DeLouis


"Stuart" wrote in message
...
I create a workbook with just one sheet, and make sure that
range("A1") is not Locked. With this book as the activeworkbook,
I run this code:

Sub Test_Protection()
Dim ws As Worksheet, c As Range
For Each ws In ActiveWorkbook.Worksheets
With ws
.Unprotect
For Each c In .UsedRange.Columns("A:G")
With c
If Not c.Locked = True Then
'User is permitted to edit this cell, so color it:
c.Interior.ColorIndex = 34
End If
If Not .Range("A1").Locked = True Then
.Range("A1").Interior.ColorIndex = 34
End If
End With
Next
End With
Next
End Sub

In this example, the 'c' code does not recognise that "A1" is
not Locked, but the "A1" code does, and the cell is coloured
correctly.

Why is the line 'If Not c.Locked = True Then' failing please?

Regards.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.692 / Virus Database: 453 - Release Date: 28/05/2004






---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.692 / Virus Database: 453 - Release Date: 28/05/2004