EXCEL1: Workbook Protection, Single Click

aacod

Well-known Member
Joined
Mar 20, 2009
Messages
667
I want to protect a 31 Sheet excel workbook with data in cells ranging from A1:N54 on each of the 31 sheets. Each sheet tab is labelled as 1 Mar, 2 Mar, 3 Mar and so on till 31 Mar.

Condition:
Following Cells & Columns must be protected.

Protect Cell B4
Protect Cell K4, K5, K6
Protect Cell L4, L5, L6
Protect Cell K8
Protect Cell C54, H54, M54


Protect Column D, E, J, I and N

Other cells and columns left unprotected for user to select and/or input data.

Thanks.
 
Last edited:

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
ok then maybe try:

Code:
Sub protectdata()
For Each ws In Worksheets
    ws.Cells.Locked = False
    ws.Range("B4,K4:K6,L4:L6,K8,C54,H54,M54,D:D,E:E,J:J,I:I,N:N").Locked = True
    ws.Protect
Next ws
End Sub
Hope that helps.
 
Upvote 0
How do I unprotect all the sheets, once I protect it with this code? Cause I forgot to mention that I have Macros which donot work after protection. the code for the macro is:

Sub RED1()
'
' RED1 Macro
' Macro recorded 3/24/2009 by Staff
'
'
Selection.Interior.ColorIndex = 3
End Sub
 
Last edited:
Upvote 0
yes that is what the bold part does:

ws.Range("B4,K4:K6,L4:L6,K8,C54,H54,M54,D:D,E:E,J:J,I:I,N:N").Locked = True
 
Upvote 0
<HR style="COLOR: #ffffff; BACKGROUND-COLOR: #ffffff" SIZE=1> <!-- / icon and title --><!-- message -->
How do I unprotect all the sheets, once I protect it with this code? Cause I forgot to mention that I have Macros which donot work after protection. the code for the macro is:

Sub RED1()
'
' RED1 Macro
' Macro recorded 3/24/2009 by Staff
'
'
Selection.Interior.ColorIndex = 3
End Sub
 
Upvote 0
I would like to unprotect the all the 31 sheets with a code and macro buttons to work when all the sheets are protected, if possible.

thanks.
 
Upvote 0
<HR style="COLOR: #ffffff; BACKGROUND-COLOR: #ffffff" SIZE=1><!-- / icon and title --><!-- message -->
How do I unprotect all the sheets, once I protect it with this code? Cause I forgot to mention that I have Macros which donot work after protection. the code for the macro is:

Sub RED1()
'
' RED1 Macro
' Macro recorded 3/24/2009 by Staff
'
'
Selection.Interior.ColorIndex = 3
End Sub
You could do something like:

Code:
Sub RED1()
'
' RED1 Macro
' Macro recorded 3/24/2009 by Staff
'
'
activesheet.unprotect
Selection.Interior.ColorIndex = 3
activesheet.protect
End Sub
Hope that helps.
 
Upvote 0

Forum statistics

Threads
1,203,182
Messages
6,053,974
Members
444,695
Latest member
asiaciara

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