Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

General discussion

protecting cells with formula's in them

Nov 3, 2004 8:58PM PST

Hi, I want to protect a number of cells with formula's in them from the user accidently wiping out the formula by typing in the cell. The formula in the cell changes depending on the number they input in other cells. I forget how to protect them.

Discussion is locked

- Collapse -
It's in the Help.
Nov 3, 2004 10:57PM PST

Or did you also forget how to reach the Help of Excel? That's Help from the menu bar.

In a nutshell:
Format>Cell properties>Protection
combined with
Tools>Protection
to enable your formatting.

Kees

- Collapse -
Re: It's in the Help.
Nov 3, 2004 11:21PM PST

I found it after I looked at help and I figured that part out, sorry I didn't post that right awaySad I do however have another problem. I have a few macro's which clear out the excel sheet and basically start with the entered amounts all blanked out for some cells as well as hide some rows, and then unhide them as needed. With the sheet protected, I get a run time error. I tried to use
Sheets(?sheetname?).UnProtect userinterfaceonly:=true
which I have found on google but that did not help. I am getting a Run-time error '1004': Unable to set the hidden property of the range class. Any idea how to fix that?

- Collapse -
Use the macrorecorder.
Nov 4, 2004 2:51AM PST

This is what it records if I do it from the keyboard (comment added) in Excel 97.

' Protect
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True

' Unprotect
ActiveSheet.Unprotect

Apparently, something is wrong with userinterfaceonly. It might be that it's version dependent. Luckily, each version comes with it's own macrorecorder, so you won't have any problem to find out what to use.

I don't have any doubt that you can substitute:
Sheets("Sheet1") for ActiveSheet, but if you want to do other things on the screen there's no objection to make it the active sheet first. This is the code for it (I first guessed it, then checked it through recording):

' Make sheet active
Sheets("Sheet1").Select

Hope this helps.


Kees

- Collapse -
Re: Use the macrorecorder.
Nov 4, 2004 3:13AM PST

That worked like a charm!! Thank you Kees. I appreciate it, I don't know why I didn't think of the macro recorder in the first place.

- Collapse -
(NT) (NT) You're welcome.
Nov 4, 2004 3:31AM PST