![]() |
Password for cell protection within VBA
I have a VBA routine where the user inputs several items & then clicks
a "calc" button to get an answer that is then entered into a certain cell by the VBA code. I want to enable protection (w/password) so that only the user input cells can be selected/edited. I added code for the calc button to unprotect the sheet, enter the answer into the cell, and then turn protection back on. My problem is that upon execution of the line that unprotects the sheet, a dialog box pops up for the user to enter the "protection" password, which they of course do not have. How can I use VBA code to provide the password? |
Password for cell protection within VBA
Mike,
hard code the password ActiveSheet.Unprotect Password:="MyPass" 'do things ActiveSheet.Protect Password:="MyPass" Mike "Mike" wrote: I have a VBA routine where the user inputs several items & then clicks a "calc" button to get an answer that is then entered into a certain cell by the VBA code. I want to enable protection (w/password) so that only the user input cells can be selected/edited. I added code for the calc button to unprotect the sheet, enter the answer into the cell, and then turn protection back on. My problem is that upon execution of the line that unprotects the sheet, a dialog box pops up for the user to enter the "protection" password, which they of course do not have. How can I use VBA code to provide the password? |
All times are GMT +1. The time now is 05:22 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com