Lock/protect active sheet if value on cell meet

PPPAAARRR

New Member
Joined
Oct 4, 2018
Messages
2
Hello to all,

I'm new to VBA but can understand some.
I need help regarding locking/protecting the active sheet when the value on cell matches my required value.
For example,
The value will appear on column D. If a value appear on D is "REJECT" the active sheet will become protected.
But before the value on D appear, it must satisfy the condition on column B and C. Cells on column B and C are under formula as well as column D.
The data on column B is dependent on column A1 and data on column C is dependent on A2.
Pls see below

A
B
C
D
1
1
OK
OK
ACCEPT
2
1



3
1
OK
NG
REJECT
4
2



5





<tbody>
</tbody>









Data on column A are from scanner, so I need to finish scanning to have data on column B and C and to have data on column D.

Thanks in advance for any help you could give me.
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Hi. See if the code below, which should go into the module of the proper worksheet, could be a start.
Code:
Private Sub Worksheet_Calculate()
 If Application.CountIf([D:D], "REJECT") Then ActiveSheet.Protect
End Sub
 
Upvote 0
Hi @Osvaldo,

Thank you for your reply.
But the code still don't lock the active sheet when "REJECT" value on column D.
I still input data on column A.
 
Upvote 0

Forum statistics

Threads
1,217,391
Messages
6,136,324
Members
450,005
Latest member
BigPaws

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