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

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
I may have worded this poorly. I will need every cell to become uneditable once this macro has run.
 
Upvote 0

Forum statistics

Threads
1,216,558
Messages
6,131,400
Members
449,648
Latest member
kyouryo

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