This article was previously published under Q162715
This article has been archived. It is offered "as is" and will no longer be updated.
This article contains information about using the DataEntryMode property inMicrosoft Excel and includes a sample Microsoft Visual Basic forApplications macro.
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to 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 requirements. The DataEntryMode property allows you to select and type data only intounlocked cells in the current selection (the data entry area). When youwant to enter data only in a specific part of your worksheet, use theDataEntryMode property. You can then use that part of the worksheet as asimple data form.
In data entry mode, you can move the active cell and select cell rangesonly in the data entry area. Pressing the arrow keys, the TAB key, orSHIFT+TAB moves the active cell from one unlocked cell to the next unlockedcell. When you reach the end of a column, the active cell moves to thefirst or last unlocked cell in the next or previous column. Pressing theHOME or END keys moves the active cell to the first or last cell in thedata entry area. You cannot select entire rows or columns or click a cellthat is outside the data entry area to select it.
The only commands that are available while you are in data entry mode arecommands that are normally available in protected worksheets.
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.
The following example starts data entry mode for the cell range A1:B10and 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 isended.
You can also assign the macro Test3 to a button on the worksheet. When youclick the button, data entry mode is ended.
For additional information, please see the following article in theMicrosoft Knowledge Base: