PC Review


Reply
Thread Tools Rate Thread

How can I make arrow keys skip over cells?

 
 
MaverickPS@gmail.com
Guest
Posts: n/a
 
      14th Dec 2007
I created some VBA code that pops up a little date picker calendar
whenever specific cells become activated. Problem is that when people
are moving around in the spreadsheet with the arrow keys and they hit
one of these cells the calendar pops up and stops them.

I want to make it so that the arrow keys skip over these cells and the
pop-up only happens when the cell is clicked with the mouse. Any ideas?
 
Reply With Quote
 
 
 
 
MaverickPS@gmail.com
Guest
Posts: n/a
 
      14th Dec 2007
On Dec 13, 6:24 pm, Maveric...@gmail.com wrote:
> I created some VBA code that pops up a little date picker calendar
> whenever specific cells become activated. Problem is that when people
> are moving around in the spreadsheet with the arrow keys and they hit
> one of these cells the calendar pops up and stops them.
>
> I want to make it so that the arrow keys skip over these cells and the
> pop-up only happens when the cell is clicked with the mouse. Any ideas?


no ideas anyone?
 
Reply With Quote
 
Tim Zych
Guest
Posts: n/a
 
      14th Dec 2007
Assuming the worksheet_selectionchange is being used, here's one way.

In a regular module:

Declare Function GetKeyState Lib "user32" _
(ByVal nVirtKey As Long) As Integer

Private Const VK_LEFT = &H25
Private Const VK_UP = &H26
Private Const VK_RIGHT = &H27
Private Const VK_DOWN = &H28

Public Function ArrowKeyPressed() As Boolean
If GetKeyState(VK_LEFT) < 0 Or GetKeyState(VK_RIGHT) < 0 Or _
GetKeyState(VK_UP) < 0 Or GetKeyState(VK_DOWN) < 0 Then
ArrowKeyPressed = True
Else
ArrowKeyPressed = False
End If
End Function

In the worksheet module:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not ArrowKeyPressed Then
MsgBox Target.Address & " was selected without an arrow key."
End If
End Sub


I got the arrow key constants at:
http://safari.java.net/0672319330/ch09lev1sec3
so you can add more as needed (Tab, Enter, etc).

An alternative is to only test for the left-mouse button being pressed and
let the selectionchange event run only then, but I could not get that to
work (&H01). I saw a workaround but have not tried it, so you may want to
search online for some other options or include additional key detections,
creating a more robust function. This is just an example.


--
Tim Zych
SF, CA

<(E-Mail Removed)> wrote in message
news:8183d1eb-23fd-4857-970b-(E-Mail Removed)...
>I created some VBA code that pops up a little date picker calendar
> whenever specific cells become activated. Problem is that when people
> are moving around in the spreadsheet with the arrow keys and they hit
> one of these cells the calendar pops up and stops them.
>
> I want to make it so that the arrow keys skip over these cells and the
> pop-up only happens when the cell is clicked with the mouse. Any ideas?



 
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
How do i make the arrow keys tab to the next cell? Nadine Microsoft Excel Misc 1 26th Jul 2009 01:48 AM
Arrow navigation needs to skip over cells MaverickPS@gmail.com Microsoft Excel Discussion 1 14th Dec 2007 03:19 AM
Is it possible to set the enter and arrow keys to skip locked cel =?Utf-8?B?QmFycm9u?= Microsoft Excel Misc 2 18th Mar 2006 08:03 AM
Skip cells with TAB/SHIFT+TAB but allow arrow keys/mouse selection of skipped cells Wescotte Microsoft Excel Programming 1 6th Jun 2005 07:00 PM
Datagrid and Arrow keys, how to make the arrow move around? Joe Microsoft Dot NET Framework Forms 2 9th Jan 2004 04:50 PM


Features
 

Advertising
 

Newsgroups
 


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