ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Trapping the Escape key when a dropdown validation list is display (https://www.excelbanter.com/excel-programming/409120-trapping-escape-key-when-dropdown-validation-list-display.html)

Pete Rooney

Trapping the Escape key when a dropdown validation list is display
 
Good afternoon,

I have some event code that when any cell in a certain range (which has
validation referring to a worksheet list), a SENDKEY Down is sent and the
screen display is zoomed up, to make reading of the drop down list easier.
Once the user makes a selection from the list, the display is zoomed back
down again.
However, if when the validation list is displayed, if the Escape key is
pressed, the display size remains the same. I have an ONKEY command, but it
only works if the ESCAPE key is pressed subsequently (i.e. you need to press
it twice).

Is there a way by which VBA can detect that the Escape key was pressed when
a validation list was displayed?

Here's the code:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Zoom and simulate dropdown click when a cell in "ColWONo, ColA" is
selected

Application.OnKey "{ESC}", "Zoom120"
ActiveWindow.Zoom = 120

If Target.Cells.Count = 1 Then 'Check that the selected cell is a single
cell
If Not Intersect(Target, Range("ColWOActivityRole")) Is Nothing Then
ActiveWindow.Zoom = 150
Application.SendKeys ("%{DOWN}")
End If
End If
End Sub



Thanks in advance

Pete


All times are GMT +1. The time now is 05:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com