Forum Discussion
VBA code for password to open excel
Here is a sample file to insert the password.
Have you fished from the Internet before long time not had more the side. I have used this example a few times with good results. You can of course make it even better.
I hope to make some amends could 🙂
Hope I was able to help you.
Nikolino
I know I don't know anything (Socrates)
- mtarlerNov 03, 2020Silver Contributor
amitmahapatra similar to NikolinoDE I recommend showing a sheet upon opening but using that sheet to make sure the user knows that macros must be enabled and I would also put a button on that sheet to "Login". I would also recommend that you lock the macro project so people don't circumvent your macro/password.
- amitmahapatraNov 03, 2020Copper Contributor
Really thanks so much for all the help and its shaping into what i am looking for but little far off.. What you are proposing is to have 1 sheet with a button or something to ask for password .. but it allows to open the excel sheet.
But I am looking for password to be prompt when opening the excel sheet (through Macro or VBA) as attached the attached file...
Do you guys think that can be possible ?
- mtarlerNov 04, 2020Silver Contributor
amitmahapatra So I assume you know you can do this using built in Excel protection but it sounds like you specifically want a Macro solution. In the attached I modified NikolinoDE solution to hide the protected sheets. However, I keep 1 "public" sheet visible (hide all the other sheets) so you can prompt the user with information. It can be frustrating to a user that opens a locked workbook and sees nothing and no password prompt because of their security settings. I would also recommend locking the macro project but left it unlocked for you to work with easier. And if you insist you can delete/hide that public sheet also, I just don't recommend it.