Trapping the Escape key when a dropdown validation list is display

P

Pete Rooney

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top