Prompt others only for password

NickUsaMi

New Member
Joined
Oct 15, 2015
Messages
20
Hello Excel Experts,
how can I require other users to enter password if they try to make changes to any of the file content?
PS. If I open it to modify, no need for password. If others open it to modify, ask for password. No password required for Read-only.
in another word, I have excel file saved on shared drive, or on the network, that is mine, or created by me. I would like to have it available to others but as read only.
I want to be able to open and modify the file without password from my PC, or login. however, if other users opens it (not from my PC, or Login) I want Excel to prevent any changes by others unless they input the password.
I hope I got it explained correctly.
thanks for the help.
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
run UserWantsToEdit() , if you, it will unlock the wb for you. otherwise ask user

Code:
public const kPASS = "wbPassword"

sub UserWantsToEdit()
if IsMeNick() then
    UnlockWB
else
vRetval = Inputbox("Enter Password", "Workbook has password")
if vRetval = "" then exit sub
 
if vRetval = kPass then
    UnlockWB
else
   msgbox "Invalid Password"
endif
end sub

private function IsMeNick() as boolean
 IsMeNick=  getUserID() = "NickUsaMi"      'my userlong
end function

Public Function getUserID() As String
getUserID = Environ("Username")
End Function

private sub     UnlockWB()
  'apply workbook password here
end sub
 
Upvote 0
thank you very much ranman256 for your help, but where do i paste this in VBA?
also only 1 place i have to change my user name?
i modified this section below, but did not work
IsMeNick= getUserID() = "NickUsaMi" 'my userlong
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,942
Members
449,094
Latest member
teemeren

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