Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default Determine when Enter Key is pressed in a sheet??

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 ??
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 269
Default Determine when Enter Key is pressed in a sheet??

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 ??
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Determine when Enter Key is pressed in a sheet??

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
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
Setting up an Excel sheet to automatically determine when an employeeshould enter a retirement plan, perhaps What-If Analysis would help? Anyother suggestions? Enda80 Links and Linking in Excel 0 December 21st 08 12:28 PM
Select sheet, Pause till Enter pressed, return to previous sheet Russ3Z Excel Programming 1 June 12th 07 11:06 PM
How do I determine what key was pressed notso Excel Programming 0 April 7th 07 06:04 PM
how do I ensure enter is pressed busyman5_au Excel Programming 3 February 27th 04 04:25 PM
Enter pressed in Textbox embarrased Excel Programming 6 February 5th 04 06:24 PM


All times are GMT +1. The time now is 05:09 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"