+ Reply to Thread
Results 1 to 7 of 7

Click on a cell to run a macro

  1. #1
    Registered User
    Join Date
    01-15-2009
    Location
    england
    MS-Off Ver
    Excel 2010
    Posts
    37

    Click on a cell to run a macro

    Hi All, New here and a bit of a novice.
    I want to be able to click on a cell eg. C9 and run 1 macro, Click on C10 and run another macro etc.
    I would prefer not to have button.

    What is the best way?

  2. #2
    Forum Contributor
    Join Date
    08-19-2006
    Posts
    116
    Quote Originally Posted by luffield View Post
    Hi All, New here and a bit of a novice.
    I want to be able to click on a cell eg. C9 and run 1 macro, Click on C10 and run another macro etc.
    I would prefer not to have button.

    What is the best way?
    Hi

    You can with this:

    Alt+F11 and paste the following

    Please Login or Register  to view this content.
    Close the window. Double click and the macro will be executed.It's an example.
    Last edited by Raiby; 01-18-2009 at 05:38 AM.

  3. #3
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480
    This can be done with a Worksheet Event
    Place this code into the Worksheet Module by right clicking on the sheet tab and selecting View Code, Paste the code there....
    Please Login or Register  to view this content.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Ralby

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  5. #5
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387
    luffield,

    You can use the Worksheet_SelectionChange Event to accomplish your request.


    Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

    Right click the sheet tab you want the code in, and click on View Code. Paste the below code there (on the right pane).


    Please Login or Register  to view this content.


    Press and hold down the 'ALT' key, and press the 'F11' key.

    On the 'Insert' menu, click 'Module'.

    Copy the below code, and paste it into the Module (on the right pane).


    Please Login or Register  to view this content.

    Then click on either cell C9 or C10.


    Have a great day,
    Stan
    Last edited by stanleydgromjr; 01-17-2009 at 09:58 AM.
    Have a great day,
    Stan

    Windows 10, Excel 2007, on a PC.

    If you are satisfied with the solution(s) provided, please mark your thread as Solved by clicking EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  6. #6
    Registered User
    Join Date
    01-15-2009
    Location
    england
    MS-Off Ver
    Excel 2010
    Posts
    37
    Thanks very much for your help

  7. #7
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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