+ Reply to Thread
Results 1 to 10 of 10

Change Yes/No value by clicking on cell

  1. #1
    Registered User
    Join Date
    06-20-2011
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    91

    Change Yes/No value by clicking on cell

    Hi...I need some help with a code please for when a user clicks on a cell the value in that cell changes to a "yes" and if they click in that cell again it changes to a"no". This should be a loop.

    I will have a few cells like this in the worksheet. So will use the code at each I need to work this way.

    These cells will be used for calculations elsewhere in the workbook.

    I'd be very grateful for some help on this please. Thanks
    Last edited by fusion007; 06-23-2011 at 04:32 AM.

  2. #2
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Change Yes/No value by clicking on cell

    Hi Fusion007, I don't know if this fulfills your requirements but I got this code:
    Please Login or Register  to view this content.
    to work but you would have to double click the cell and then click out of it for it to run the Worksheet_Change event.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  3. #3
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: Change Yes/No value by clicking on cell

    Enter this into your worksheet module:
    Please Login or Register  to view this content.

    Of course you would need to adapt it for the ranges you want to specify.

    I believe, however, that the chance of a user accidentally selecting or clicking on the cell and changing its value is rather high. I would recommend using the BeforeDoubleClick event, rather than the SelectionChange event.

    Please Login or Register  to view this content.
    Last edited by Whizbang; 06-22-2011 at 05:03 PM.

  4. #4
    Registered User
    Join Date
    06-20-2011
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    91

    Re: Change Yes/No value by clicking on cell

    Hi Whizbang...nothing happens when I double click in Cell A1. I like your idea about the user accidently clicking on the cell and hence changing the value.

    Hi Mordred...It works but I would like to specify each individual cell where I want this yes/no to operate and ideally it to work without the user having to move off the cell

  5. #5
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Change Yes/No value by clicking on cell

    Hey fusion, I would say to try whizbang's again but be sure to capitalize your first letters.

  6. #6
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Change Yes/No value by clicking on cell

    From Whizbang's code, slightly modified to accept a lower case yes:
    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.

  7. #7
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Change Yes/No value by clicking on cell

    Please Login or Register  to view this content.



  8. #8
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Change Yes/No value by clicking on cell

    You make it look so easy snb!

  9. #9
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Change Yes/No value by clicking on cell

    I'm so sorry, I didn't want to offend you ...

  10. #10
    Registered User
    Join Date
    06-20-2011
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    91

    Re: Change Yes/No value by clicking on cell

    Thank you all for taking the time to reply. snb I've used your code as I can easily define the ranges.
    Thanks again.

+ 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