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
[TABLE="width: 417, align: left"]
<tbody>[TR]
[TD]
[/TD]
[TD]A
[/TD]
[TD]B
[/TD]
[TD]C
[/TD]
[TD]D
[/TD]
[/TR]
[TR]
[TD]1
[/TD]
[TD]1
[/TD]
[TD]OK
[/TD]
[TD]OK
[/TD]
[TD]ACCEPT
[/TD]
[/TR]
[TR]
[TD]2
[/TD]
[TD]1
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]3
[/TD]
[TD]1
[/TD]
[TD]OK
[/TD]
[TD]NG
[/TD]
[TD]REJECT
[/TD]
[/TR]
[TR]
[TD]4
[/TD]
[TD]2
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]5
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
</tbody>[/TABLE]









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

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
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,223,228
Messages
6,170,875
Members
452,363
Latest member
merico17

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