Color Unlocked Cells
My customer had a number of workbooks, each having up to 20 worksheets in each one.
He was trying to unlock some cells and lock down the headings and formula cells.
The good thing about this macro is that it can be run multiple times against the same sheets so if you are constantly changing and checking your work, you get immediate gratification. My new customer had a more complicated worksheet that I need to have more criterias. 2024 update is essentially a complete re-write.
Option Explicit
Sub ColorActive()
Dim IteM As Variant
Dim SheetR As Integer
Dim DdD As String
Dim F As Long
Dim O As Long
Dim L As Long
Dim SheetC As Integer
SheetR = 0
SheetC = ActiveWorkbook.Worksheets.Count
DdD = ActiveSheet.Name
Worksheets(DdD).Activate
For Each IteM In ActiveSheet.UsedRange
If IteM.Locked = False And IteM.Formula = True Then
IteM.Interior.ColorIndex = xlAutomatic
F = F + 1
ElseIf IteM.Locked = False Then
IteM.Interior.Color = &HAF1E9A9
SheetR = SheetR + 1
O = O + 1
ElseIf IteM.Locked = True Then
IteM.Interior.ColorIndex = xlAutomatic
L = L + 1
End If
Next
MsgBox SheetR & F & " Formulas were skipped," & O & " cells were colored, and " & L _
& " locked cells were skipped on " & DdD, 64
End Sub
|