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

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
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,214,653
Messages
6,120,751
Members
448,989
Latest member
mariah3

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