PC Review


Reply
Thread Tools Rate Thread

Determine when Enter Key is pressed in a sheet??

 
 
Subodh
Guest
Posts: n/a
 
      12th Mar 2010
I want to determine when Enter key is pressed in a sheet that is
active??
I would like then to run a macro when the Enter key is pressed ??
 
Reply With Quote
 
 
 
 
Paul C
Guest
Posts: n/a
 
      12th Mar 2010
The Enter Key is not a capturable event.

Worksheet change is
This added to the individual worksheet in VBA will trigger when ever the
sheet is changed.

Private Sub Worksheet_Change(ByVal Target as Range)
'Do Stuff
End Sub

If you are going to make changes to the sheet using this event is is usually
a good idea to turn off events at the start and then turn them back on at the
end. Otherwise the changes trigger this macro again.

Private Sub Worksheet_Change(ByVal Target as Range)
Application.EnableEvents=False
'Do Stuff
Application.EnableEvents=True
End Sub




--
If this helps, please remember to click yes.


"Subodh" wrote:

> I want to determine when Enter key is pressed in a sheet that is
> active??
> I would like then to run a macro when the Enter key is pressed ??
> .
>

 
Reply With Quote
 
Hubisan
Guest
Posts: n/a
 
      12th Mar 2010
It is possible with application.onkey. Example is with HOME-Key, for
other keys check VBA help inside Excel or look for it on the web:

Sub StartOnKey()
'Run this sub to make the HOME-key run the "SubHello" procedure
Application.OnKey "{HOME}", "SubHello"
End Sub

Sub SubHello()
'Pressing HOME will run this procedure
MsgBox "hallo"
End Sub

Sub StopOnKey()
'Run this sub to return HOME-Key to its normal meaning.
Application.OnKey "{HOME}"
End Sub

You can use Workbook_Open() and run application.onkey to bind a
procedure to a key as soon as the workbook is opened.

Hubisan

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting up an Excel sheet to automatically determine when an employeeshould enter a retirement plan, perhaps What-If Analysis would help? Anyother suggestions? Enda80 Microsoft Excel Programming 1 21st Dec 2008 02:27 PM
Setting up an Excel sheet to automatically determine when an employeeshould enter a retirement plan, perhaps What-If Analysis would help? Anyother suggestions? Enda80 Microsoft Excel Worksheet Functions 0 21st Dec 2008 12:26 PM
Select sheet, Pause till Enter pressed, return to previous sheet Russ3Z Microsoft Excel Programming 1 12th Jun 2007 11:06 PM
How do I determine what key was pressed =?Utf-8?B?bm90c28=?= Microsoft Excel Programming 0 7th Apr 2007 06:04 PM
How can you determine if the Laptop Fn key is pressed? =?Utf-8?B?c2NwYXJrZXI2Mg==?= Microsoft Dot NET Framework Forms 0 5th Jan 2005 06:39 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:47 PM.