ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Select locked/unlocked cells (https://www.excelbanter.com/excel-programming/417400-select-locked-unlocked-cells.html)

Training Goddess

Select locked/unlocked cells
 
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


[email protected]

Select locked/unlocked cells
 
Hi Training Goddess (cool name!)
Search this group using

select all locked/unlocked cells

-always search as a first option.
regards
Paul

On Sep 22, 2:57*am, 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



Mike H

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



All times are GMT +1. The time now is 09:47 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com