I have created a multi-sheet workbook with several VBA codes running and I want to make sure people can't mess it up. Is there a way to make sure people can only input information into certain cells and run the codes from the buttons?
Unlock the cells where you want to input data and lock those cells you don't want changed. Then protect the sheet. In order for your macros to run properly you will have to place your code between "unprotect" and "protect" as shown below:
'your code here
Change "MyPassword" (in red) to match the password you use when protecting the sheet.
The sheet protection, with or without a password, prevents any changes in the cells that were locked. The macros will still run when you click the buttons without having to enter any password. I believe that is what you wanted. Did you want to prevent changes to certain cells or did you want to prevent changes to the code in the macros?
The instructions in Post #2 and the macro I suggested will protect the locked cells from being changed. To protect your code, you have to protect your VBA Project. Do the following:
-hold down the ALT key and press the F11 key to open the Visual Basic Editor
-click on 'Tools' on the top menu
-click 'VBAProject Properties'
-click the 'Protection' tab
-click the box to the left of 'Lock project for viewing' to put a check mark in it
-enter your password and then confirm it and click 'OK'
-close the VB Editor
-save your workbook as a macro-enabled file and close it
When you re-open the file, you will not be able to see the macros unless you enter the password. Keep in mind that this type of protection is not very strong and anyone who really wants to get at your macros can probably do it with a little research. I hope this helps.