Determining if selection change was the result of ENTER
How can I code vba to determine if the selection change on a worksheet was
the result of pressing the ENTER key? |
Determining if selection change was the result of ENTER
You can capture the key press of the enter key (note there are two enter
keys) something like this... With Application .OnKey "{Enter}", "MyMacro" .OnKey "~", "MyMacro" End With The macro MyMacro will have to mimic a normal enter but that is just seleting the cell you want... Check out this link... http://msdn.microsoft.com/library/de...HV05203370.asp -- HTH... Jim Thomlinson "joeeng" wrote: How can I code vba to determine if the selection change on a worksheet was the result of pressing the ENTER key? |
Determining if selection change was the result of ENTER
The problem is that I only want this to trigger on one worksheet, and only if
the {ENTER} results in an intersection with particular cells. I can't see how I can make the OnKey work for this circumstance. I might be missing something though. "Jim Thomlinson" wrote: You can capture the key press of the enter key (note there are two enter keys) something like this... With Application .OnKey "{Enter}", "MyMacro" .OnKey "~", "MyMacro" End With The macro MyMacro will have to mimic a normal enter but that is just seleting the cell you want... Check out this link... http://msdn.microsoft.com/library/de...HV05203370.asp -- HTH... Jim Thomlinson "joeeng" wrote: How can I code vba to determine if the selection change on a worksheet was the result of pressing the ENTER key? |
Determining if selection change was the result of ENTER
I have figured out to accomplish this. Place the OnKey calls in the
beginning of the Worksheet_Activate and Worksheet_SelectionChange subroutines. Then reset the OnKeys in the Worksheet_Deactivate and at the end of the OnKey macros. "joeeng" wrote: The problem is that I only want this to trigger on one worksheet, and only if the {ENTER} results in an intersection with particular cells. I can't see how I can make the OnKey work for this circumstance. I might be missing something though. "Jim Thomlinson" wrote: You can capture the key press of the enter key (note there are two enter keys) something like this... With Application .OnKey "{Enter}", "MyMacro" .OnKey "~", "MyMacro" End With The macro MyMacro will have to mimic a normal enter but that is just seleting the cell you want... Check out this link... http://msdn.microsoft.com/library/de...HV05203370.asp -- HTH... Jim Thomlinson "joeeng" wrote: How can I code vba to determine if the selection change on a worksheet was the result of pressing the ENTER key? |
All times are GMT +1. The time now is 08:51 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com