View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bill Renaud Bill Renaud is offline
external usenet poster
 
Posts: 417
Default Onkey Key Codes for ADD and SUBTRACT keys in earlier Excel version

I use Excel 2000 (SP-3) and got the following to work:

'----------------------------------------------------------------------
Public Sub KeysOn()
Application.OnKey "{107}", "IncrementCell"
Application.OnKey "{109}", "DecrementCell"
End Sub

'----------------------------------------------------------------------
Public Sub KeysOff()
Application.OnKey "{107}"
Application.OnKey "{109}"
End Sub

'----------------------------------------------------------------------
Public Sub IncrementCell()
With ActiveCell
.Value = .Value + 1
End With
End Sub

'----------------------------------------------------------------------
Public Sub DecrementCell()
With ActiveCell
.Value = .Value - 1
End With
End Sub

I found the following Microsoft web page had a listing of all of the
keyboard codes:

Key Code Constants (ActiveX Controls)
http://msdn2.microsoft.com/en-us/lib...67(vs.71).aspx

To read these tables, use the Description column on the right to find the
key you are interested in, then get the value from the middle column
("Value"). It will be in hexadecimal, so strip off the "&H" part on the
left side, then convert the remaining characters from HEX to Decimal. So,
for example:

Constant Value Description
------------- ----- ----------------------
vbKeyAdd &H6B PLUS SIGN (+) key
vbKeySubtract &H6D MINUS SIGN (-) key

For the + key: 6B HEX is 107 decimal.
For the - key: 6D HEX is 109 decimal.
--
Regards,
Bill Renaud