I am using Excel where certain fields are allowed for user input and other cells are to be protected. I have used Tools Protect sheet, however after doing this I am not able to change the values in the VBA script. I need to restrict the sheet to stop user input, at the same time allow the VBA code to change the cell values based on certain computations.
Protecting cells in Excel but allow these to be modified by VBA script
Re: Protecting cells in Excel but allow these to be modified by VBA script
Try using
`Worksheet.Protect “Password”, UserInterfaceOnly := True
If the `UserInterfaceOnly` parameter is set to true, VBA code can modify protected cells.
Note however that this parameter [does not stick](https://stackoverflow.com/a/14162717/11683). It needs to be reapplied each time the file is opened.