Results 1 to 5 of 5

VBA distinguish between right click and left click

This is a discussion on VBA distinguish between right click and left click within the Excel Questions forums, part of the Question Forums category; hi guys i've been using excel for a while but this problem simply baffles me. i have a popup calendar ...

  1. #1
    Board Regular
    Join Date
    Jun 2005
    Posts
    215

    Default VBA distinguish between right click and left click

    hi guys

    i've been using excel for a while but this problem simply baffles me. i have a popup calendar that shows every time a user clicks on a certain cell. however i dont want it to popup if the user right-clicks on that cell. is there a way in vba to distinguish between when the user left clicked his mouse or right clicked?

    thanks in advance

  2. #2
    Board Regular Domski's Avatar
    Join Date
    Jan 2005
    Location
    Leeds, UK
    Posts
    7,178

    Default Re: VBA distinguish between right click and left click

    When you say it kicks off when a user clicks on a cell what event code are you using to detect this?

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    - Guidelines For Posting

    - Mr Excel Articles and PodCasts

    - Display sheet using HTML Maker or Excel Jeanie

    - Something that makes me laugh

    - Please try to remember to use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Board Regular
    Join Date
    Jun 2005
    Posts
    215

    Default Re: VBA distinguish between right click and left click

    hey

    im using the SelectionChange event to show the calendar.

  4. #4
    MrExcel MVP lenze's Avatar
    Join Date
    Feb 2002
    Location
    Helena, MT
    Posts
    13,690

    Default Re: VBA distinguish between right click and left click

    You probably have a WorkSheet_SelectionChange event that triggers the calendar when this cell is selected. Unfortunately, a Right click involves selecting the cell, thus getting the pop-up. I suggest you fine the code. RightClick the sheet tab and Choose "View Code". Replace this line
    Code:
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    wit
    Code:
    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    Cancel = True
    This will now require a DoubleClick to call the calendar.
    HTH
    lenze
    If you have to tell your boss you're good with Excel, you're NOT!!
    All I know about Excel I owe to my ignorance!
    Scotch: Because you don't solve great Excel problems over white wine

  5. #5
    Board Regular
    Join Date
    Jun 2005
    Posts
    215

    Default Re: VBA distinguish between right click and left click

    hey lenze. ur everywhere lol !!!!

    as for the code....works perfectly ! thanks ALOT ! ur the best

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


DMCA.com