Change cell protection based on cell value macro

Seanzies

Board Regular
Joined
Nov 19, 2005
Messages
212
I have a one time use macro that is needed in order to change a bunch off cells protection to either locked or unlocked.

I want it to only change the cell protection if the cell value is equal to 1. I have part of the code below but don't know the rest of ithe criteria needed.

Code Example:
Columns("D:AA").Select
Selection.Locked = False
Selection.FormulaHidden = False
End Sub
 

Some videos you may like

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

BrianB

Well-known Member
Joined
Feb 17, 2003
Messages
8,127
This checks all cells in the selection. You may like to delete the first line and select manually to reduce the run time.

Code:
    Columns("D:AA").Select
    For Each c In Selection.Cells
        If c.Value = 1 Then
            c.Locked = False
            c.FormulaHidden = False
        End If
    Next
 

Watch MrExcel Video

Forum statistics

Threads
1,118,452
Messages
5,572,209
Members
412,448
Latest member
ManuW
Top