Select locked/unlocked cells
Maybe
Sub mariner()
Dim MyState As Boolean
Dim MyType As String
Dim MyRange As Range, C As Range
response = InputBox("Select What? Locked (L) or Unlocked (U)")
If response = vbCancel Then Exit Sub
Select Case UCase(response)
Case "L"
MyState = True
MyType = "Unlocked"
Case "U"
MyState = False
MyType = "Locked"
Case Else
Exit Sub
End Select
For Each C In ActiveSheet.UsedRange
If C.Locked = MyState Then
If MyRange Is Nothing Then
Set MyRange = C
Else
Set MyRange = Union(MyRange, C)
End If
End If
Next C
If MyRange Is Nothing Then
MsgBox "All cells are " & MyType
Else
MyRange.Select
End If
End Sub
Mike
"Training Goddess" wrote:
I came across an excellent procedure here in the Excel Programming discussion
group last week but didn't capture it to disk. Would someone be able to
provide the code to select all locked/unlocked cells on a worksheet?
MUCH appreciated!
Training Goddess
|