+ Reply to Thread
Results 1 to 30 of 30

Change cell value to "1" by mouseclick

  1. #1
    Registered User
    Join Date
    01-06-2014
    Location
    Estonia
    MS-Off Ver
    Excel 2003
    Posts
    21

    Change cell value to "1" by mouseclick

    Hi,
    I haven't touched Excel in a while and it seems I'm totally unable to get anything working anymore

    I need to make cells E5 to E39 act so that if I click on one, the empty cell gets value "1". It would be even better if the second click would make it "2", third "3" and so on, but if that's too complicated, just one click to "1" will do.. can anyone help me out? I can't even get my macros to show up..

    The file is here: http://www14.zippyshare.com/v/FL8O0lnu/file.html
    Although, in theory the file is not even needed

    I'd really appreciate help.

    Thank you guys in advance!

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Change cell value to "1" by mouseclick

    Since more than one cell at a time could be clicked, this will evaluate all currently selected cells, this goes in the SHEET module.
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    01-06-2014
    Location
    Estonia
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Change cell value to "1" by mouseclick

    Woah Thank You! [rep added]
    This will pretty much do! Although, do You have any idea if it's possible to make it so that if I do two or three clicks on one cell, it will increase. Because at the moment, I have to click on another cell and then again on the first cell for it to increase. Two or more clicks won't work if I don't click on another cell in between..
    Last edited by joh123; 02-03-2017 at 03:24 PM.

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Change cell value to "1" by mouseclick

    We can fake it by moving the selected cell off that clicked cell(s).
    Please Login or Register  to view this content.
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  5. #5
    Registered User
    Join Date
    01-06-2014
    Location
    Estonia
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Change cell value to "1" by mouseclick

    You, Sir, are brilliant!
    I also replaced
    Please Login or Register  to view this content.
    with
    Please Login or Register  to view this content.
    so I can also delete the value if needed (otherwise it'd be impossible) and also otherwise it will leave a trail of ones if I move around with keyboard arrows.

    But all in all, it's perfect now and I sincerely thank You for Your time!
    Greetings!

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Change cell value to "1" by mouseclick

    Smart change. Good job.

  7. #7
    Registered User
    Join Date
    01-06-2014
    Location
    Estonia
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Change cell value to "1" by mouseclick

    Hi!
    Now I've encountered another and rather unexpected problem. I was planning to use the worksheet on a Windows 10 tablet with touchscreen, yet Excel doesn't seem to register the touches the same as clicks - so the value will not change and all that happens is the cell going active.

    What do you guys think, is there a workaround?
    Greets!

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Change cell value to "1" by mouseclick

    Nope. Sorry.

    https://answers.microsoft.com/en-us/...f-b1c49da34c73

    Quote Originally Posted by Kate Edson
    There are a few Office features that are not available in Office 2013 for Windows RT:
    http://office.microsoft.com/en-us/ho...103210361.aspx
    Like macros and forms.
    These features are available in the Windows 8 version of Office 2013. You can use Office 2013 on Surface with Windows 8 Pro.
    Hope this helps,
    Kate

  9. #9
    Valued Forum Contributor
    Join Date
    03-24-2014
    Location
    England
    MS-Off Ver
    Excel 2003 - 2016
    Posts
    575

    Re: Change cell value to "1" by mouseclick

    Quote Originally Posted by joh123 View Post
    Hi!
    Now I've encountered another and rather unexpected problem. I was planning to use the worksheet on a Windows 10 tablet with touchscreen, yet Excel doesn't seem to register the touches the same as clicks - so the value will not change and all that happens is the cell going active.
    What tablet? My MS-Surface Pro 3 recognises touches as clicks....

  10. #10
    Registered User
    Join Date
    01-06-2014
    Location
    Estonia
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Change cell value to "1" by mouseclick

    Tried on iPad 2 (with MS Excel) and a friend tried on his (don't know which one). It works if I connect a mouse to the tablet - so VBA itself works, but with this solution posted above it doesn't when I "click" with my finger

  11. #11
    Valued Forum Contributor
    Join Date
    03-24-2014
    Location
    England
    MS-Off Ver
    Excel 2003 - 2016
    Posts
    575

    Re: Change cell value to "1" by mouseclick

    There's your problem. iPad. I could go off on my usual rant about how Apple do everything half arsed AND produce their hardware in sweatshops in asia with child labour AND still manage to charge more for their kit than could possibly be justified but......I won't. Damn, too late.

    Buy a proper windows tablet and it'll work.

  12. #12
    Registered User
    Join Date
    01-06-2014
    Location
    Estonia
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Change cell value to "1" by mouseclick

    Quote Originally Posted by BellyGas View Post
    There's your problem. iPad. I could go off on my usual rant about how Apple do everything half arsed AND produce their hardware in sweatshops in asia with child labour AND still manage to charge more for their kit than could possibly be justified but......I won't. Damn, too late.

    Buy a proper windows tablet and it'll work.
    Yeah, I don't like them either. But still, I tried it on an iPad and also on a Win10 tablet and it was the same Gotta try it on another Win10 tablet then before reaching any conclusions, I guess. Thanks for the input.

  13. #13
    Valued Forum Contributor
    Join Date
    03-24-2014
    Location
    England
    MS-Off Ver
    Excel 2003 - 2016
    Posts
    575

    Re: Change cell value to "1" by mouseclick

    Or try a win8 tablet.

  14. #14
    Registered User
    Join Date
    01-06-2014
    Location
    Estonia
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Change cell value to "1" by mouseclick

    Okay, I tried it on a Win8 Lenovo Thinkpad Yoga-something tablet and it won't work. However, it seems that the touch activates it totally differently. See these pictures:

    A regular click activates a cell like this:
    1mouseclick.png

    and double-click does what it should - increases the value of the cell by 1

    Now, a touch activates a cell like this:
    1touch.png

    And a double-touch like this:
    2touch.png
    and now I can write in the cell..

    Maybe these pictures help to resolve the problem..

    Do any of you have any idea?

  15. #15
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Change cell value to "1" by mouseclick

    No, my understanding from the link I noted previously is that this isn't going to work.

  16. #16
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Change cell value to "1" by mouseclick

    Quote Originally Posted by joh123 View Post
    Tried on iPad 2 (with MS Excel) and a friend tried on his (don't know which one). It works if I connect a mouse to the tablet - so VBA itself works, but with this solution posted above it doesn't when I "click" with my finger
    Pardon the interruption- are you saying that VBA is working in Excel on an iPad?
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  17. #17
    Registered User
    Join Date
    01-06-2014
    Location
    Estonia
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Change cell value to "1" by mouseclick

    Well, how come it works on BellyGas' tablet then.. He said previously that "My MS-Surface Pro 3 recognises touches as clicks...."..

  18. #18
    Valued Forum Contributor
    Join Date
    03-24-2014
    Location
    England
    MS-Off Ver
    Excel 2003 - 2016
    Posts
    575

    Re: Change cell value to "1" by mouseclick

    It definitely does. I'm using it right now.

  19. #19
    Registered User
    Join Date
    01-06-2014
    Location
    Estonia
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Change cell value to "1" by mouseclick

    Quote Originally Posted by BellyGas View Post
    It definitely does. I'm using it right now.
    Hi, BellyGas

    Are we sure we're talking about the same thing?

    In this file - http://www99.zippyshare.com/v/FqOW9pNl/file.html - in E-column, does double-touching on cells under "Määrä" increase cell value by 1?

    Thanks in advance if you're willing to try the actual file..

  20. #20
    Valued Forum Contributor
    Join Date
    03-24-2014
    Location
    England
    MS-Off Ver
    Excel 2003 - 2016
    Posts
    575

    Re: Change cell value to "1" by mouseclick

    Nope....but not cos it's a touchscreen:

    You've put your macro in the worksheet before double click event, it should be in the worksheet selection change event. Forget double clicking. Even double clicking with a mouse won't trigger it.

    You're using too many variables. Forget 'cell' just use 'target', it's already been defined. And that rubbish you've got in the actual important bit is not needed. Your macro should be as simple as target.value = target.value + 1. There is no need for anything else inside the range selection part.

  21. #21
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Change cell value to "1" by mouseclick

    BellyGas, the original macro was a Worksheet_SelectionChange event, so the "cell" (garbage?) came from that, the need to be able to trap and proceed if more than one cell is selected. I agree converting it to a BeforeDoubleClick event means it is no longer needed, just giving you the history on how it got there.

    As a doubleclick event it does what they intend with a mouse.

  22. #22
    Valued Forum Contributor
    Join Date
    03-24-2014
    Location
    England
    MS-Off Ver
    Excel 2003 - 2016
    Posts
    575

    Re: Change cell value to "1" by mouseclick

    Not on my 2 laptops (1 with a touchscreen, 1 without). Double clicking with a mouse on both does nothing.

  23. #23
    Valued Forum Contributor
    Join Date
    03-24-2014
    Location
    England
    MS-Off Ver
    Excel 2003 - 2016
    Posts
    575

    Re: Change cell value to "1" by mouseclick

    Silly question: Why is it necessary for this to happen on a double click? Why not a single? Post #1 says it would be nice if it went to 2, 3, etc, on subsequent clicks.....so why does this need to be on a double click?

    The code becomes very simple if it's a single click.

    Please Login or Register  to view this content.
    Last edited by BellyGas; 02-20-2017 at 11:39 AM.

  24. #24
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Change cell value to "1" by mouseclick

    The OP wanted the ability to select cells normally across the sheet without incrementing, then only getting the +1 effect when they specifically double-click. I would have opted to stay with the original SelectionChange approach from post #2. But that's me. I get the benefits of both.

  25. #25
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Change cell value to "1" by mouseclick

    A double-click would also have the benefit of allowing you to increment the same cell repeatedly.

  26. #26
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Change cell value to "1" by mouseclick

    Hehe, I can't help but note that changing a 1 to a 5 with doubleclicks can be characterized as "inefficient". I can do that in 2 keystrokes by typing

  27. #27
    Valued Forum Contributor
    Join Date
    03-24-2014
    Location
    England
    MS-Off Ver
    Excel 2003 - 2016
    Posts
    575

    Re: Change cell value to "1" by mouseclick

    That's what the Range("A1").select command is for. You can click the same cell repeatedly with it incrementing every time.

    And yeah, repeatedly double clicking is just going to give the OPs manager the idea he's playing Counterstrike.

  28. #28
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Change cell value to "1" by mouseclick

    Quote Originally Posted by BellyGas View Post
    That's what the Range("A1").select command is for.
    Yes but that would have the minor side effect of not letting you select anything else on the sheet.

  29. #29
    Registered User
    Join Date
    01-06-2014
    Location
    Estonia
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Change cell value to "1" by mouseclick

    Woah, so many posts. Well, to be honest, I rarely need the value to be more than 1 or blank. So no Counter Strike :D But one click (instead of double) would render me unable to delete the value if I happen to change my mind.

    It seems you guys are alot smarter than me and I got pretty confused by all your comments now :P But how come this file doesn't work for you, even with a mouse? Works for me. It just wont work on a touchscreen.. and so far I can't understand if its possible at all or not. I mean it works on a touchscreen computer with a physical mouse attached but won't work using the touchscreen..

  30. #30
    Valued Forum Contributor
    Join Date
    03-24-2014
    Location
    England
    MS-Off Ver
    Excel 2003 - 2016
    Posts
    575

    Re: Change cell value to "1" by mouseclick

    Quote Originally Posted by xlnitwit View Post
    Yes but that would have the minor side effect of not letting you select anything else on the sheet.
    Doh, he's right. Move it to within the target not intersect part and it'll be fine.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. "Worksheet change" not changing cell on other sheet to match target cell "fill".
    By Ochimus in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 10-02-2015, 12:02 PM
  2. Replies: 5
    Last Post: 07-16-2015, 10:14 AM
  3. [SOLVED] How to USE """"" cells count """"" change font color
    By austin123456 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-09-2013, 06:14 AM
  4. Change "Parent" cell based on results of multiple "Children" cells
    By ccowman in forum Excel Formulas & Functions
    Replies: 16
    Last Post: 12-14-2012, 02:33 AM
  5. Replies: 1
    Last Post: 10-31-2010, 02:56 AM
  6. Replies: 3
    Last Post: 07-27-2008, 06:31 AM
  7. cell to change color =IF(B7>53,"Critical","Normal")
    By fgiord in forum Excel General
    Replies: 3
    Last Post: 08-18-2005, 05:05 PM

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