ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Lock/Unlock cells (https://www.excelbanter.com/excel-worksheet-functions/116047-lock-unlock-cells.html)

BFife

Lock/Unlock cells
 
Is there a way to "preview" the locked/unlocked cells in worksheet?

Paul B

Lock/Unlock cells
 
BFife, this macro may help, will select the lock or unlocked cells in the
selection

Sub SelectedLockedUnlockedCells()

'will select the locked or unlocked cells in the selection


Dim myCell As Range
Dim myRange As Range
Dim SelLocked As Boolean
Dim myReply As Variant
myReply = MsgBox("Select Locked = ""Yes""" & Chr(10) & _
"Select UnLocked = ""No""", vbYesNoCancel)
If myReply = vbCancel Then Exit Sub

For Each myCell In Selection
If myReply = vbYes And myCell.Locked Then
If myRange Is Nothing Then
Set myRange = myCell
Else
Set myRange = Union(myRange, myCell)
End If
End If
If myReply = vbNo And Not myCell.Locked Then
If myRange Is Nothing Then
Set myRange = myCell
Else
Set myRange = Union(myRange, myCell)
End If
End If
Next myCell
If myRange Is Nothing Then
MsgBox "No " & IIf(myReply = vbYes, "Locked", "Unlocked") & _
" cells found in the current selection."
Exit Sub
End If
myRange.Select
End Sub
--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003


"BFife" wrote in message
...
Is there a way to "preview" the locked/unlocked cells in worksheet?




PCLIVE

Lock/Unlock cells
 
This will highlight all locked cells that are not empty.

Sub HighlightLockedCells()

For Each cell In Range("A1:" &
Range("A1").SpecialCells(xlLastCell).Address)
If cell.Value < "" _
Then If cell.Locked = True _
Then cell.Interior.ColorIndex = 6
Next cell

End Sub


"BFife" wrote in message
...
Is there a way to "preview" the locked/unlocked cells in worksheet?





All times are GMT +1. The time now is 10:58 PM.

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