ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Password Protect - put password in a cell in the workbook (https://www.excelbanter.com/excel-programming/371934-password-protect-put-password-cell-workbook.html)

Mike R.

Password Protect - put password in a cell in the workbook
 
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

[email protected]

Password Protect - put password in a cell in the workbook
 
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



Mike R.

Password Protect - put password in a cell in the workbook
 
Worked perfect. Thanks

" wrote:

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





All times are GMT +1. The time now is 02:24 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com