+ Reply to Thread
Results 1 to 6 of 6

Run macro when cell is clicked but NOT selected

  1. #1
    Registered User
    Join Date
    01-09-2011
    Location
    Santiago, Chile
    MS-Off Ver
    Excel 2003
    Posts
    51

    Run macro when cell is clicked but NOT selected

    Hi guys!

    Is it possible to run a macro when a cell is clicked (with the mouse arrow) but NOT when is selected with, say, the keyboard?

    i.e I want to run a macro when A2 is clicked but not when I change my active cell with the keyboard arrows.

    thanks

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Run macro when cell is clicked but NOT selected

    Why? Why not use double-click and selection?

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,463

    Re: Run macro when cell is clicked but NOT selected

    I'm not sure that you can differentiate how the cell has been "accessed".

    For example, if you press Enter, the cursor will move down, to the right, or to the next unlocked cell (if the sheet protection is set) depending on your setup. If you press tab, you'll have a similar effect.

    If you use the mouse, any cell could have been selected previously. However, pressing F5 (Go To) and putting in a cell address would look the same.

    There's no "Mouse Over" event AFAIK.

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,482

    Re: Run macro when cell is clicked but NOT selected

    It may be best just to place a button on cell A2.
    It can be a button, picture,autoshape or even the rectangle from the drawings toolbar.
    Right click on the object and select assign macro..

    If you use the rectangle...
    select the rectangle to draw
    press the Alt button and select the cell you want to place it on
    click at the top left corner and drag to the bottom right corner of the cell.

    This will place the rectangle perfectly in the cell. Right click and assign the macro to it.

  5. #5
    Registered User
    Join Date
    01-09-2011
    Location
    Santiago, Chile
    MS-Off Ver
    Excel 2003
    Posts
    51

    Re: Run macro when cell is clicked but NOT selected

    Mmm.. then i'll change it to double click i suppose

    Thank you

  6. #6
    Valued Forum Contributor jwright650's Avatar
    Join Date
    12-10-2010
    Location
    Va, USA
    MS-Off Ver
    Excel 2003, Excel 2010
    Posts
    606

    Re: Run macro when cell is clicked but NOT selected

    Can you hide a textbox behind the cell?....you can still arrow through that cell and it would not active the macro, but if you mouse click, it will activate.


    EDIT#2:Whoops, Dave already suggested this.....
    Attached Files Attached Files
    Last edited by jwright650; 01-31-2011 at 08:50 AM. Reason: edit#1added example xls, edit#2added comment
    Life is like a roll of toilet paper. The closer it gets to the end, the faster it goes.
    John Wright

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1