VBA to protect cell in excel

Closed
hemu - Nov 3, 2015 at 04:43 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Nov 3, 2015 at 11:10 AM
Hello,

Hello,
I need a help if some one can help me.
i a fresh in excel vba code writing. please provide a code to protect a cell with password when the cell value is yes, and if the value is no un protect.
Thanks in advance.

Related:

1 response

TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 555
Nov 3, 2015 at 11:10 AM
Hi Hemu,

Since you are new to VBA, you should get familiar with the macro recorder.

Start by unblocking all cells except the one cell. The option can be found under the Protection tab of Cell Properties.

Then record a macro > protect and unprotect sheet with password.
Check to see how that looks like.

Use that recorded code together with a logic like:
If range(your cell) = "Yes" then
use the protect sheet part
elseif range(your cell) = "No" then
use the unprotect sheet part
end if

Let us know how it goes.

Best regards,
Trowa
0