MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Protecting cells in VBA


Posted by Tom C. on April 27, 2001 11:36 AM

I want to protect cells in the worksheet that have formulas in them, meaning I don't want the user to see the formulas nor do I want the user to be able to modify the cell contents. I have tried the following code:
worksheets("name").range("a1:j10").formulahidden=true
worksheets("name").range("a1:j10").protect=true

None of those statements works. I don't get an error message when I run the code. Please help!! Thanks very much.

Tom


Posted by Malc on April 27, 2001 1:37 PM

Protect the cells normally through the format cells menu then in the macro
ActiveWorksheet.protect
ActiveWorksheet.unprotect
you can put passwords on here but I never bother because users will eventually find out what the password is or you'll forget it.