Macro to unprotect sheet, unlock selected cells and protect sheet again

Mylarbi

New Member
Joined
Feb 9, 2020
Messages
48
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
I hope someone will be able to help me with this please.
To start with, I have created and protected a worksheet with password "thisisprotected".
Data entry cells are unlocked and formula cells are locked.
Ocassionally, the user may need to temporarily unprotect the sheet to modify any protected/locked cell and protect the sheet again.
What I want to do now is get a macro code for this. So the steps will be;

-The user will first select the cells they want to modify. Then they will run the macro with a shortcut.
The macro will;
1. unprotect the sheet with password "thisisprotected"
2. unlock the selected cells
3. protect the sheet again with password "thisisprotected".
Thanks
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Code:
Sub BlahBlah()
    ActiveSheet.Unprotect Password:="thisisprotected"
    Selection.Locked = False
    Selection.FormulaHidden = False
    ActiveSheet.Protect Password:="thisisprotected"
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,440
Messages
6,124,882
Members
449,193
Latest member
PurplePlop

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