Password Protect - put password in a cell in the workbook

G

Guest

Hi - I have some VB code that runs throughout my workbook and it does a lot
of protecting/un protecting of sheets. I have hard-coded the password into
the vb code. I am fearful that if I need to change the password, I will not
change it everywhere. I would like to instead put the password on my data
sheet and then have the vb code refer to cell A1 on sheet1 to get the
password. Is this possible?
Thanks,
Mike
 
H

halimnurikhwan

Hi Mike,
You can do this:

Sub password()
dim Pass as string
Pass = InputBox("Password:", "type your password!")
Sheet1.[a1].value = Pass
Activesheet.Protect Pass
End Sub

Rgds,

Halim

Mike R. menuliskan:
 
G

Guest

Worked perfect. Thanks

Hi Mike,
You can do this:

Sub password()
dim Pass as string
Pass = InputBox("Password:", "type your password!")
Sheet1.[a1].value = Pass
Activesheet.Protect Pass
End Sub

Rgds,

Halim

Mike R. menuliskan:
Hi - I have some VB code that runs throughout my workbook and it does a lot
of protecting/un protecting of sheets. I have hard-coded the password into
the vb code. I am fearful that if I need to change the password, I will not
change it everywhere. I would like to instead put the password on my data
sheet and then have the vb code refer to cell A1 on sheet1 to get the
password. Is this possible?
Thanks,
Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top