XL: EnableSelection Property May be Overridden

Last reviewed: February 4, 1998
Article ID: Q157102
The information in this article applies to:
  • Microsoft Excel 97 for Windows
  • Microsoft Excel 98 Macintosh Edition

SYMPTOMS

If you use the EnableSelection property of a worksheet to restrict certain cells from being selected, you may still be able to select the restricted cells. For example, if you use the following code to prevent selection of locked cells:

   ActiveSheet.EnableSelection = xlUnlockedCells

it may still be possible to select locked cells.

CAUSE

This occurs because the EnableSelection property does not prevent you from selecting cells using the Name box on the Formula bar.

Also, you can use a macro to select cells, even if they are locked, by using a line of code similar to the following:

   Range("B5").Select

RESOLUTION

Even though you can select restricted cells, if the cells are locked and the worksheet is protected, you cannot change them.

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

You can use the EnableSelection property of a worksheet to determine what, if any, cells on a worksheet may be selected by the user. EnableSelection has three possible values:

   Value              Definition
   ---------------------------------------------------------------------

   xlNoRestrictions   Any cell can be selected.
   xlNoSelection      No cells can be selected.
   xlUnlockedCells    If the worksheet is protected, only cells that are
                      unlocked can be selected.

You can unlock a cell or group of cells by following these steps:

  1. Select the cell(s) to be unlocked.

  2. On the Format menu, click Cells. Click the Protection tab.

  3. Clear the Locked check box. Click OK.

If the worksheet is protected and you have set the EnableSelection property to xlUnlockedCells, you cannot select locked cells, either by clicking them with the mouse or by using the Go To dialog box.

However, you can select locked cells by using the Name box on the Formula bar. If you click the Name box, type in a cell reference (D5, for example) or a range reference (D5:E10, for example), and then press Enter, the indicated cell or range will be selected.

Because the cells are locked and the worksheet protected, they cannot be changed. You can still copy or fill from a locked cell into unlocked cells without receiving any error messages.


Additional query words: XL97 XL98 vba vbe
Keywords : xlvbahowto xlvbainfo xlformat kbcode kbprb kbprg kbusage
Version : WINDOWS:97; MACINTOSH:98
Platform : MACINTOSH WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 4, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.