B
BEEJAY
The main body of this code is currently operated from an icon, on active
sheet only.
It is lightning fast.
This code is now required elsewhere, to loop thru each worksheet, or,
better yet, thru specified worksheets - lets call them A, B, C, D, E.
Please help.
Sub UnLocked_Cells()
' Non Locked Cells make Yellow
' Locked Cells make "blank" (if not already so before)
Dim ws As Worksheet
Application.ScreenUpdating = False
For Each ws In ActiveWorkbook.Worksheets
If ws.ProtectContents = True Then
ws.Unprotect ("xxxx")
End If
Next
ActiveWorkbook.Unprotect (["yyyy"])
' The next section is to loop thru the specified worksheets
' ================================
Dim CELL As Range, tempR As Range, rangeToCheck As Range
Cells.Select
' The Following ONE line is an addition to a working Macro
Cells.Interior.ColorIndex = -4142
For Each CELL In Intersect(Selection, ActiveSheet.UsedRange)
If Not CELL.Locked Then
If tempR Is Nothing Then
Set tempR = CELL
Else
Set tempR = Union(tempR, CELL)
End If
End If
Next CELL
If tempR Is Nothing Then
MsgBox "There are no Unlocked cells " & _
"in the selected range."
End
End If
'Select qualifying cells
'TempR.Select
tempR.Interior.ColorIndex = 6 'yellow
' =================================================
End Sub
sheet only.
It is lightning fast.
This code is now required elsewhere, to loop thru each worksheet, or,
better yet, thru specified worksheets - lets call them A, B, C, D, E.
Please help.
Sub UnLocked_Cells()
' Non Locked Cells make Yellow
' Locked Cells make "blank" (if not already so before)
Dim ws As Worksheet
Application.ScreenUpdating = False
For Each ws In ActiveWorkbook.Worksheets
If ws.ProtectContents = True Then
ws.Unprotect ("xxxx")
End If
Next
ActiveWorkbook.Unprotect (["yyyy"])
' The next section is to loop thru the specified worksheets
' ================================
Dim CELL As Range, tempR As Range, rangeToCheck As Range
Cells.Select
' The Following ONE line is an addition to a working Macro
Cells.Interior.ColorIndex = -4142
For Each CELL In Intersect(Selection, ActiveSheet.UsedRange)
If Not CELL.Locked Then
If tempR Is Nothing Then
Set tempR = CELL
Else
Set tempR = Union(tempR, CELL)
End If
End If
Next CELL
If tempR Is Nothing Then
MsgBox "There are no Unlocked cells " & _
"in the selected range."
End
End If
'Select qualifying cells
'TempR.Select
tempR.Interior.ColorIndex = 6 'yellow
' =================================================
End Sub