Lock all cells in workbook

All2Cheesy

Board Regular
Joined
Mar 4, 2015
Messages
127
Hi all,

I've currently got a macro which locks all sheets in a workbook, although certain cells remain editable. (See below)

What I'll need to do is create a second macro, which locks every cell in every sheet of a workbook, without interfering with the functionality of the first lock.

Is this possible? Or might there be another way to go about this?

Assistance would be greatly appreciated. :)

Code:
Sub SalesManagerLock()

    Dim S As Object
    Dim pWord1 As String, pWord2 As String
    pWord1 = InputBox("Please Enter the password")
    If pWord1 = "" Then Exit Sub
    pWord2 = InputBox("Please re-enter the password")
     
    If pWord2 = "" Then Exit Sub
     'make certain passwords are identical
    If InStr(1, pWord2, pWord1, 0) = 0 Or _
    InStr(1, pWord1, pWord2, 0) = 0 Then
        MsgBox "You entered different passwords. No action taken"
        Exit Sub
    End If
    For Each Worksheet In Worksheets
        Worksheet.Protect Password:=pWord1
    Next
 
 End Sub
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Forum statistics

Threads
1,223,236
Messages
6,170,912
Members
452,366
Latest member
TePunaBloke

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