Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default How can I make arrow keys skip over cells?

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?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default How can I make arrow keys skip over cells?

On Dec 13, 6:24 pm, 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?
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default How can I make arrow keys skip over cells?

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

wrote in message
...
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
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
Cannot navigate between cells using arrow keys Jim Gardner Excel Discussion (Misc queries) 2 November 20th 09 03:53 PM
How do i make the arrow keys tab to the next cell? Nadine Excel Discussion (Misc queries) 1 July 26th 09 01:48 AM
Arrow keys when cells locked sam Excel Worksheet Functions 1 September 26th 08 01:41 PM
Is it possible to set the enter and arrow keys to skip locked cel Barron Excel Discussion (Misc queries) 2 March 18th 06 08:03 AM
Skip cells with TAB/SHIFT+TAB but allow arrow keys/mouse selection of skipped cells Wescotte Excel Programming 1 June 6th 05 07:00 PM


All times are GMT +1. The time now is 02:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"