View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default Single Digit Entry

Tushar

I must learn to never say "never"<g

Gord

On Tue, 20 Apr 2004 16:52:30 -0400, Tushar Mehta
<tm_200310@tushar_hyphen_mehta_dot_see_oh_em wrote:

There is a somewhat cumbersome way of doing this. You have to define a
OnKey procedure for each of the numbers. For example, the following
will cause the active cell to change as soon as someone types the number
7. Run the testOnKey procedure to enable the automatic change to the
active cell. The resetOnKey will return the functionality of the 7 key
to its default status. The OnKeySub does the actual work.

Sub testOnKey()
Application.OnKey "7", "OnKeySub"
End Sub
Sub resetOnKey()
Application.OnKey "7"
End Sub
Sub OnKeySub()
ActiveCell.Value = 7
ActiveCell.Offset(0, 1).Select
End Sub

At the very least you will have to set the OnKey procedure for each of
the numeric keys. Combine that with validation for non-numeric values.

Alternatively, you will have to define the OnKey procedure for *every*
keystroke. And, you can skip the validation stuff.