ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to Unprotect save worksheet and protect it again. (https://www.excelbanter.com/excel-programming/368909-macro-unprotect-save-worksheet-protect-again.html)

holy41

Macro to Unprotect save worksheet and protect it again.
 
I need a macro to unprotect cells B6:O6 and protect them back.
I would appreciate your help .

Thank Ken Calhoun

Tom Ogilvy

Macro to Unprotect save worksheet and protect it again.
 
Activesheet.Unprotect Password:="ABC"
Range("B6:O6").Locked = False
Activesheet.Protect Password:="ABC"





Activesheet.Unprotect Password:="ABC"
Range("B6:O6").Locked = True
Activesheet.Protect Password:="ABC"

--
Regards,
Tom Ogilvy


"holy41" wrote:

I need a macro to unprotect cells B6:O6 and protect them back.
I would appreciate your help .

Thank Ken Calhoun


Simon Lloyd[_844_]

Macro to Unprotect save worksheet and protect it again.
 

This should do exactly as you asked!

Regards,
Simon

Sub Test()
ActiveSheet.Unprotect
Range("B6:O6").Select
Selection.Locked = False
Selection.FormulaHidden = False

'WHATEVER YOU WANT TO DO WITH THE CELLS HERE

Range("B6:O6").Select
Selection.Locked = True
Selection.FormulaHidden = False
ActiveSheet.Protect DrawingObjects:=True, Contents:=True
Scenarios:=True
ActiveWorkbook.Save
End Su

--
Simon Lloy
-----------------------------------------------------------------------
Simon Lloyd's Profile: http://www.excelforum.com/member.php...nfo&userid=670
View this thread: http://www.excelforum.com/showthread.php?threadid=56681



All times are GMT +1. The time now is 08:34 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com