Skip to main content

Range.Locked property

Table of contents
  1. Syntax
  2. Remarks
  3. Example

Returns or sets a Variant value that indicates if the object is locked.

Syntax

expression.Locked

expression A variable that represents a Range object.

Remarks

This property returns True if the object is locked, False if the object can be modified when the sheet is protected, or Null if the specified range contains both locked and unlocked cells.

Example

This example unlocks cells A1:D20 on Sheet1 so that they can be modified when the sheet is protected.

Worksheets("Sheet1").Range("A1:D20").Locked = False 
Worksheets("Sheet1").Protect

Leave a comment

Your email address will not be published. Required fields are marked *

Format your code: <pre><code class="language-vba">place your code here</code></pre>