+ Reply to Thread
Results 1 to 9 of 9

Change event macro - Select cell

  1. #1
    Registered User
    Join Date
    10-11-2007
    Posts
    14

    Change event macro - Select cell

    Hello all,

    I've got a question about some VBA programming. What I would like to do is when a user clicks on a certain cell on one of my worksheets I would like a message box to pop up.

    First off I am not sure which event handler to put the code as none of them seem really suitable.

    Then the code I am also not sure of. I've tried something like:

    Please Login or Register  to view this content.
    That doesn't seem to work. I also have already used the built in data validation on the cell so I can't do it that way either.

    Can anyone help me?

    Thank you all!

  2. #2
    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
    Right click the summary sheet > select view code and paste in the below

    Please Login or Register  to view this content.
    VBA Noob
    _________________________________________


    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 !!!

  3. #3
    Registered User
    Join Date
    10-11-2007
    Posts
    14
    Thanks for the reply but that does not seem to work.

    Do you think it could be because cell F15 is actually merged with G15? usually I just reference it with F15 and it works like that but I did try "F$15:G$15" didnt work either. Any other ideas?

  4. #4
    Registered User
    Join Date
    10-11-2007
    Posts
    14
    Actually, no, it can't be because of the merged cell as I tried it in one that was not merged and it doesn't work.

  5. #5
    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
    Yes it's the merge.

    Try

    Please Login or Register  to view this content.
    VBA Noob

  6. #6
    Registered User
    Join Date
    10-11-2007
    Posts
    14
    Ok great, at first that wasn't working for me but I saved it, closed the workbook and opened it and it started working.

    Thanks so much for your help Mr. Noob :P

  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
    Glad it helped

    VBA Noob

  8. #8
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885
    I tried VBA's code on a non-merged cell and it worked just fine. I then tried his updated code on a merged cell and it worked, too.

    Remember, this isn't a CLICK event code, it's a SELECTION CHANGE event code. Cells don't have a CLICK event. If cell F15 were selected, and you click on it again it will not trigger the macro. But if any other cell were selected and you either clicked on F15 or used arrow keys to move to that cell the macro will trigger because the SELECTION is CHANGING.

  9. #9
    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

+ 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