PC Review


Reply
Thread Tools Rate Thread

BeforeRightClick event vs. Selection Change

 
 
DennisB
Guest
Posts: n/a
 
      28th Oct 2008
I have two events that fire when I change the active cell, a BeforeRightClick
and Selection Change. If I select a new cell by right clicking, the code for
the selection change fires. How do I stop the selection change event when I
right click?
 
Reply With Quote
 
 
 
 
Peter T
Guest
Posts: n/a
 
      28th Oct 2008
Private Declare Function GetAsyncKeyState Lib "User32" _
(ByVal vKey As Long) As Long


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If GetAsyncKeyState(2&) Then Exit Sub ' right mouse down

End Sub

declare the API function as Public and put it in a normal module if you want
to call it from multiple modules

Regards,
Peter T

"DennisB" <(E-Mail Removed)> wrote in message
news:FBFE48CC-F999-4F6D-A65C-(E-Mail Removed)...
>I have two events that fire when I change the active cell, a
>BeforeRightClick
> and Selection Change. If I select a new cell by right clicking, the code
> for
> the selection change fires. How do I stop the selection change event when
> I
> right click?



 
Reply With Quote
 
DennisB
Guest
Posts: n/a
 
      28th Oct 2008
Peter,

I learned something new! This worked great, thank you so much.

Dennis

"Peter T" wrote:

> Private Declare Function GetAsyncKeyState Lib "User32" _
> (ByVal vKey As Long) As Long
>
>
> Private Sub Worksheet_SelectionChange(ByVal Target As Range)
> If GetAsyncKeyState(2&) Then Exit Sub ' right mouse down
>
> End Sub
>
> declare the API function as Public and put it in a normal module if you want
> to call it from multiple modules
>
> Regards,
> Peter T
>
> "DennisB" <(E-Mail Removed)> wrote in message
> news:FBFE48CC-F999-4F6D-A65C-(E-Mail Removed)...
> >I have two events that fire when I change the active cell, a
> >BeforeRightClick
> > and Selection Change. If I select a new cell by right clicking, the code
> > for
> > the selection change fires. How do I stop the selection change event when
> > I
> > right click?

>
>
>

 
Reply With Quote
 
New Member
Join Date: Dec 2011
Location: Texas
Posts: 1
 
      7th Dec 2011
A while back I got this suggestion to allow my VBA right click to run rather than the selection change event.

Private Declare Function GetAsyncKeyState Lib "User32" _
(ByVal vKey As Long) As Long

This works great, but this errors on a 64 bit computer. 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
Selection Change Event pwz Microsoft Excel Programming 8 20th Nov 2009 10:58 PM
beforerightclick and selection change issue DennisB Microsoft Excel Programming 0 28th Oct 2008 02:42 PM
Selection Change Event =?Utf-8?B?SmltIFRob21saW5zb24=?= Microsoft Excel Programming 0 28th Apr 2005 05:36 PM
Selection Change Event =?Utf-8?B?SmltIFRob21saW5zb24=?= Microsoft Excel Programming 3 28th Apr 2005 10:01 AM
Combobox - change in selection and On Change event =?Utf-8?B?TGluZGE=?= Microsoft Access VBA Modules 1 4th Feb 2004 11:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:02 AM.