Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default detecting keypress(es) in a cell

As per subject... is there a way to do this?

I would like to detect the Enter key code and SHIFT+Enter keys combination.

TIA

Hernan.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default detecting keypress(es) in a cell

If the user is editing a cell, then for any practical purpose, macros don't
run.

--
Regards,
Tom Ogilvy

"Hernan" wrote in message
...
As per subject... is there a way to do this?

I would like to detect the Enter key code and SHIFT+Enter keys

combination.

TIA

Hernan.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default detecting keypress(es) in a cell

hmmm...

how about on "exiting" the cell?


"Tom Ogilvy" wrote:

If the user is editing a cell, then for any practical purpose, macros don't
run.

--
Regards,
Tom Ogilvy

"Hernan" wrote in message
...
As per subject... is there a way to do this?

I would like to detect the Enter key code and SHIFT+Enter keys

combination.

TIA

Hernan.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default detecting keypress(es) in a cell

There's a worksheet_Change event that may do what you want.

If you want to read more about events:

Chip Pearson's site:
http://www.cpearson.com/excel/events.htm

David McRitchie's site:
http://www.mvps.org/dmcritchie/excel/event.htm

Hernan wrote:

hmmm...

how about on "exiting" the cell?

"Tom Ogilvy" wrote:

If the user is editing a cell, then for any practical purpose, macros don't
run.

--
Regards,
Tom Ogilvy

"Hernan" wrote in message
...
As per subject... is there a way to do this?

I would like to detect the Enter key code and SHIFT+Enter keys

combination.

TIA

Hernan.





--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 112
Default detecting keypress(es) in a cell

I would like to detect the Enter key code and SHIFT+Enter keys combination.

Application.Onkey can be used to respond to keyboard events.


Regards,
Vic Eldridge



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default detecting keypress(es) in a cell

Good thought.

Sub SetKey()
Application.OnKey "~", "MyEnter"
Application.OnKey "+~", "MyShiftEnter"
End Sub

Sub UnSetKey()
Application.OnKey "~"
Application.OnKey "+~"
End Sub

Sub MyEnter()
MsgBox "In MyEnter"
End Sub
Sub MyShiftEnter()
MsgBox "In MyShiftEnter"
End Sub

--
Regards,
Tom Ogilvy

"Vic Eldridge" wrote in message
...
I would like to detect the Enter key code and SHIFT+Enter keys

combination.

Application.Onkey can be used to respond to keyboard events.


Regards,
Vic Eldridge



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default detecting keypress(es) in a cell

Thank you Dave and Vicfor your help on this, and you Tom for the example.


Hernan.

"Tom Ogilvy" wrote:

Good thought.

Sub SetKey()
Application.OnKey "~", "MyEnter"
Application.OnKey "+~", "MyShiftEnter"
End Sub

Sub UnSetKey()
Application.OnKey "~"
Application.OnKey "+~"
End Sub

Sub MyEnter()
MsgBox "In MyEnter"
End Sub
Sub MyShiftEnter()
MsgBox "In MyShiftEnter"
End Sub

--
Regards,
Tom Ogilvy

"Vic Eldridge" wrote in message
...
I would like to detect the Enter key code and SHIFT+Enter keys

combination.

Application.Onkey can be used to respond to keyboard events.


Regards,
Vic Eldridge




  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default detecting keypress(es) in a cell

I know this is an old, old thread.

What I want is that for cells in the named range Range("WeekDays") that on
typinging "+" the value is increased by 0.25 and on pressing "-" the value
decreased by 0.25.

What's the best way of achieving that in Excel 2003 ?

"Tom Ogilvy" wrote:

Good thought.

Sub SetKey()
Application.OnKey "~", "MyEnter"
Application.OnKey "+~", "MyShiftEnter"
End Sub

Sub UnSetKey()
Application.OnKey "~"
Application.OnKey "+~"
End Sub

Sub MyEnter()
MsgBox "In MyEnter"
End Sub
Sub MyShiftEnter()
MsgBox "In MyShiftEnter"
End Sub

--
Regards,
Tom Ogilvy

"Vic Eldridge" wrote in message
...
I would like to detect the Enter key code and SHIFT+Enter keys

combination.

Application.Onkey can be used to respond to keyboard events.


Regards,
Vic Eldridge




  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default detecting keypress(es) in a cell

I don't think you can code the + and - keys, as they put any cell directly
into edit mode. So how about the left and right arrow keys

in the code below, the tow keys set a value to increase or decrease a cell
or cells by . this handles multiple cells

Option Explicit
Sub setkeys()
Application.OnKey "{right}", "IncreaseCellValue"
Application.OnKey "{left}", "DecreaseCellValue"
End Sub

Sub unsetkeys()
Application.OnKey "{right}"
Application.OnKey "{left}"
End Sub

Sub IncreaseCellValue()
ChangeCellValue 0.25
End Sub
Sub DecreaseCellValue()
ChangeCellValue -0.25
End Sub

Sub ChangeCellValue(amount As Double)
Dim target As Range
Dim cell As Range
Set target = Intersect(Selection, Range("range1"))
If Not target Is Nothing Then
For Each cell In target
If IsNumeric(cell.Value) Then
cell.Value = cell.Value + amount
End If
Next
End If
End Sub


"SmartWombat" wrote in message
...
I know this is an old, old thread.

What I want is that for cells in the named range Range("WeekDays") that on
typinging "+" the value is increased by 0.25 and on pressing "-" the value
decreased by 0.25.

What's the best way of achieving that in Excel 2003 ?

"Tom Ogilvy" wrote:

Good thought.

Sub SetKey()
Application.OnKey "~", "MyEnter"
Application.OnKey "+~", "MyShiftEnter"
End Sub

Sub UnSetKey()
Application.OnKey "~"
Application.OnKey "+~"
End Sub

Sub MyEnter()
MsgBox "In MyEnter"
End Sub
Sub MyShiftEnter()
MsgBox "In MyShiftEnter"
End Sub

--
Regards,
Tom Ogilvy

"Vic Eldridge" wrote in message
...
I would like to detect the Enter key code and SHIFT+Enter keys

combination.

Application.Onkey can be used to respond to keyboard events.


Regards,
Vic Eldridge




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Which cell was the activecell before a keypress excelent Excel Worksheet Functions 2 May 26th 06 01:45 PM
Detecting Numbers in a cell KH_GS Excel Worksheet Functions 3 May 5th 06 02:07 AM
How can I make cell keypress event? No Name Excel Programming 0 September 13th 04 12:28 PM
How can I make cell keypress event? Tom Ogilvy Excel Programming 0 September 13th 04 12:25 PM
How can I make an excel cell keypress event? Chris DG Excel Programming 1 September 8th 04 11:39 AM


All times are GMT +1. The time now is 04:44 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"