CELL.PROTECTION(locked, hidden) Excel 4 Macro - how to use?

EggCall

New Member
Joined
Jul 1, 2017
Messages
2
Hello all,

I'm new to this board and hope you can help me with this question:

I wanted to lock and unlock a cell via Excel function rather than VBA or manually. So I found (at least I think) an Excel 4 macro for that, namely
Code:
CELL.PROTECTION(locked, hidden)
The help says:

Macro Sheets Only
Equivalent to choosing the Protection tab in the Format Cells dialog box, which appears when you choose the Cells command from the Format menu. Allows you to control cell protection and display.
Arguments are logical values corresponding to check boxes in the Protection tab. If an argument is TRUE, Microsoft Excel selects the check box; if FALSE, Microsoft Excel clears the check box. If an argument is omitted and the setting has been previously changed from the defaults, the setting is not changed.

Syntax

CELL.PROTECTION(locked, hidden)
CELL.PROTECTION?(locked, hidden)
Locked corresponds to the Locked check box. The default is TRUE.
Hidden corresponds to the Hidden check box. The default is FALSE.

Remarks

Options selected in the Protection tab of the Format Cells dialog box or with the CELL.PROTECTION function are activated only when the Protect Sheet command is chosen from the Protection submenu on the Tools menu or the PROTECT.DOCUMENT function is used to select protection.

However, when I define a name, say, LockCell with the function
Code:
CELL.PROTECT(TRUE, FALSE)
and use the name LockCell in a cell, it shows #NAME? error.

Does anyone know, what is wrong?

Thanks
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
I wanted to lock and unlock a cell via Excel function rather than <acronym title="visual basic for applications">VBA</acronym> or manually.
Excel function? You mean as what you might enter from fx?
I very much doubt if any Excel function is going to allow you to do that.
My understanding is that the "on-sheet" functions apply to the sheet surface as you see it (Conditional Formatting still falls into that as no extraneous code has been applied).
CELL as you are citing is a VBA term to be referenced via a VBA Function or Macro.
 
Upvote 0
Hello,

thanks for your reply.

Excel function? You mean as what you might enter from fx?

With Excel function I meant Excel 4.0 function/macro.

If I understand it correctly
Code:
CELL.PROTECTION(locked, hidden)
is exactly the right function what I want (see the description for that). However I can't get it work.:confused:

Any Idea?
 
Upvote 0

Forum statistics

Threads
1,223,900
Messages
6,175,276
Members
452,629
Latest member
SahilPolekar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top