Crystal Ball cannot run a simulation if a cell with Crystal Ball data is located in a write-protected worksheet. This subroutine is used to supply Crystal Ball with a worksheet password. After that, Crystal Ball uses this password to unlock the worksheet while running and lock it again afterwards.
The following commands will work after CB.WorksheetProtection is called:
Microsoft Excel Save or SaveAs
Other calls that define or modify Crystal Ball data, such as CB.DefineAssum and CB.SetAssum, also require unprotected worksheets before they will run. However, these calls are not affected by CB.WorksheetProtection. Worksheets must be manually unprotected before data-modifying calls not listed previously will work. |
Once the CB.WorksheetProtection command has run on each protected worksheet and the workbook saved, nothing else needs to be done for these commands to work.
Call CB.WorksheetProtection with the sheet you want to protect active. It only needs to be called through VBA (for example, from within the VBA Editor) one time for each sheet. Once the code has been run and the workbook saved, the code can be deleted and Crystal Ball will remember the password for future simulations.
It does not matter if the sheet is already protected when CB.WorksheetProtection is called as long as the password passed into the first parameter is consistent with the current worksheet password.