Permissions

agnerc

New Member
Joined
Jun 18, 2018
Messages
13
I added a password to my spreadsheet by going to "Save As", Tools, General Options and added a password to "Password to modify".

What I am encountering is when someone opens the file in Read Only, it is locking me out from editing.

What I am looking for is when someone opens the file in read only, I can still enter the password to edit.

Any suggestions?

Thank you,
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
.
The following is setup for Sheet1.

Paste this in the Sheet Level Module :

Code:
Option Explicit


Sub CommandButton1_Click()
Dim UserInterfaceOnly
Dim Password As String


Password = InputBox("Please enter password", "Password Required", "********")


If Password <> "PW" Then


    MsgBox "Wrong Password!"
    Exit Sub


Else
    
    Sheet1.Protect "PW", UserInterfaceOnly = True
    


End If


End Sub

Paste a CommandButton1 on Sheet 1 connected to the above macro. The password is PW

Add this macro to the ThisWorkbook Module :

Code:
Option Explicit


Private Sub Workbook_BeforeClose(Cancel As Boolean)
        Sheet1.Protect ("PW")
End Sub

The above code will lock Sheet1 so it is READ ONLY. By clicking the button and entering the correct password PW, the sheet will be unlocked for editing.
The sheet will automatically be locked again when you close the workbook via the ThisWorkbook Module macro.
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

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