XL: How to Use the DataEntryMode Property

Last reviewed: February 3, 1998
Article ID: Q162715
The information in this article applies to:
  • Microsoft Excel 97 for Windows
  • Microsoft Excel for Windows 95, versions 7.0, 7.0a
  • Microsoft Excel for Windows, versions 5.0, 5.0c
  • Microsoft Excel for Macintosh, versions 5.0, 5.0a
  • Microsoft Excel 98 Macintosh Edition

SUMMARY

This article contains information about using the DataEntryMode property in Microsoft Excel and includes a sample Microsoft Visual Basic for Applications macro.

MORE INFORMATION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

   http://www.microsoft.com/support/supportnet/refguide/default.asp

The DataEntryMode property allows you to select and type data only into unlocked cells in the current selection (the data entry area). When you want to enter data only in a specific part of your worksheet, use the DataEntryMode property. You can then use that part of the worksheet as a simple data form.

In data entry mode, you can move the active cell and select cell ranges only in the data entry area. Pressing the arrow keys, the TAB key, or SHIFT+TAB moves the active cell from one unlocked cell to the next unlocked cell. When you reach the end of a column, the active cell moves to the first or last unlocked cell in the next or previous column. Pressing the HOME or END keys moves the active cell to the first or last cell in the data entry area. You cannot select entire rows or columns or click a cell that is outside the data entry area to select it.

The only commands that are available while you are in data entry mode are commands that are normally available in protected worksheets.

Example 1

The following macro starts data entry mode:

   Sub Test1()

      Application.DataEntryMode = xlOn

   End Sub

To end data entry mode, press ESC.

NOTE: When you run the macro, the data entry area is the current selection.

Example 2

The following example starts data entry mode for the cell range A1:B10 and allows you to enter data:

   Sub Test2()

      Range("A1:B10").Select
      Selection.Locked = False
      Application.OnKey "^d", "Test3"
      Application.DataEntryMode = xlOn

   End Sub

   Sub Test3()

      Application.DataEntryMode = xlOff

   End Sub

When you press CTRL+D, the macro resumes running and data entry mode is ended.

You can also assign the macro Test3 to a button on the worksheet. When you click the button, data entry mode is ended.

For additional information, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q101567
   TITLE     : XL: Macros to Disable Keyboard Input

REFERENCES

Microsoft Excel "Function Reference," version 4.0, pages 132-133


Additional query words: 5.00 7.00 XL97 XL95
Keywords : kbcode kbprg
Version : WINDOWS: 5.0, 5.0c, 7.0, 97; MACINTOSH: 5.0, 5.0a, 98
Platform : MACINTOSH WINDOWS
Issue type : kbhowto


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 3, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.