Cells Aren't Locking

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,564
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I am using this code:
Code:
        If Application.VLookup(FacB, wshfac.Range("A:H"), 6, False) = "N" Then 'no lights
            .Range("AB24, AB26, AB25, AB27").Value = ""
            .Range("AC24, AC26").Value = "NA"
            With .Range("AB24:AE27")
                .Font.Color = RGB(224, 224, 224)
                .Locked = True
            End With
        Else 'has lights

To populate a range of cells with default values when a vlookup condition is met. If the condition is met, values are placed in the cells, the font colour changes, and the cells are supposed to lock preventing user access.

The worksheet is protected, however, I cannot get these cells to lock. Any ideas?
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Hello Ark68. You have to add code at the beginning of your macro to unprotect the sheet and then at the end to protect it again.

Code:
Activesheet.Unprotect
'Your code
Activesheet.Protect
 
Upvote 0
Thanks mumps, I appreciate your reply. The coding you suggested is already in my code ... I didn't share the whole module here. The worksheet is protected ... my other locked cells are locked.
 
Upvote 0

Forum statistics

Threads
1,215,259
Messages
6,123,922
Members
449,135
Latest member
NickWBA

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top