+ Reply to Thread
Results 1 to 10 of 10

Click and hold event on a form control spinner breaks my code

  1. #1
    Registered User
    Join Date
    08-01-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    14

    Thumbs up Click and hold event on a form control spinner breaks my code

    Hi, this is my first post! Please let me know if I'm doing it wrong

    So I have 5 form control spinners on a worksheet linked to cell values. The 5 cells are also linked such that if one of the values is increased or decreased, the other 4 also increase/decrease by some amount. I assigned a macro to the spinners so that if the user toggles up one of the spinners and the rounded cell value is greater than 10.1, then the spinner automatically toggles itself back down. For example,

    Please Login or Register  to view this content.
    Selection.Value is the value of the cell that the spinner is linked to, which was referenced using Application.Caller

    This works fine if the user single clicks the toggles. However, if the user clicks and holds the toggle, then the linked cell values get increased before the macro that's assigned to the spinner can automatically adjust the value back down.

    Is there any way to disable the click and hold event on a form control spinner? Or is there some code I can write that will allow the spinner to run through the assigned macro for each increment when the user clicks and holds the spinner? Thanks a bunch!

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Click and hold event on a form control spinner breaks my code

    Hello mansfin,

    Welcome to the Forum!

    With everything linked together when the values change, what did you expect to happen?

    If you explain what you want to achieve then a workable solution can probably be found.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Expert Tsjallie's Avatar
    Join Date
    09-15-2012
    Location
    NL
    MS-Off Ver
    2010, 2013, 2016
    Posts
    2,077

    Re: Click and hold event on a form control spinner breaks my code

    Hard to say what's happening. Can we take a look at your workbook?
    Cheers!
    Tsjallie




    --------
    If your problem is solved, pls mark the thread SOLVED (see Thread Tools in the menu above). Thank you!

    If you think design is an expensive waste of time, try doing without ...

  4. #4
    Registered User
    Join Date
    08-01-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Click and hold event on a form control spinner breaks my code

    I should have explained that if the user increments one of the spinners up and the one of the cell values rounded to to the nearest tenth is equal to 10, then all of the cell values increase from the click of the spinner. After that happens, the code from the macro that's attached to the spinner executes and automatically adjusts the spinner down one increment, so the user ends right where he/she started before clicking the spinner.

    However, when the user clicks and holds the spinner, the linked cell increments multiple times before the macro that is attached to the spinner is executed.

    I uploaded my workbook. First, increase the "Offers a variety of products" spinner by 20 increments (there is a 20 increment limit on the spinners). This will allow the spinners on the left to surpass 10.0. Next, increase "Clearly explains the programs and offerings they provide" spinner by 12 increments. Now the linked cell value is at 10.0. Next, click on it one more time. You can see the other linked cells increase, but then the assigned macro executes and the values go back down to the starting value. This is normal functionality.

    Now if you click and hold the "Clearly explains the programs and offerings they provide" spinner, then a problem arises. The spinner increments even though the cell value is already at 10.0, which is undesired. Any ideas? I'm trying to avoid using the ActiveX spinners.
    Last edited by mansfin; 10-24-2014 at 08:12 PM.

  5. #5
    Registered User
    Join Date
    08-01-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Click and hold event on a form control spinner breaks my code

    Having trouble with the attachment manager. The file isn't uploading properly.

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Click and hold event on a form control spinner breaks my code

    Hello mansfin,

    So have I. Keep trying.

  7. #7
    Registered User
    Join Date
    08-01-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Click and hold event on a form control spinner breaks my code

    Here's the file. Changing the filename fixed the problem with the attachment manager
    Attached Files Attached Files

  8. #8
    Forum Expert Tsjallie's Avatar
    Join Date
    09-15-2012
    Location
    NL
    MS-Off Ver
    2010, 2013, 2016
    Posts
    2,077

    Re: Click and hold event on a form control spinner breaks my code

    The macro is only executed when you release the spinbutton, but the spinbutton code is executed immediately and repeated as long as you hold the botton. So there's your problem.
    Guess you should move control entirely to the macro. Means that you would not link the spinbuttons to a cell but have the macro assign the spinbutton values to these cells.
    Should be something like
    Please Login or Register  to view this content.
    Tried this myself but ran into some more required adjustments. So still working on it. But this sure will be easier for you being more familiar to the code

    Extra adjustements needed come from - afaiks now - this line
    Please Login or Register  to view this content.
    So you would also need an alternative to determine the rownumber. Probably something like this
    Please Login or Register  to view this content.
    Last edited by Tsjallie; 10-25-2014 at 04:36 PM.

  9. #9
    Registered User
    Join Date
    08-01-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: Click and hold event on a form control spinner breaks my code

    Thanks a bunch!

  10. #10
    Forum Expert Tsjallie's Avatar
    Join Date
    09-15-2012
    Location
    NL
    MS-Off Ver
    2010, 2013, 2016
    Posts
    2,077

    Re: Click and hold event on a form control spinner breaks my code

    You're welcome. Thx for the rep
    If this solved your problem, pls mark the thread [Solved] (see Thread Tools).

    BTW: the --() function is a so called double unary operator. This translates TRUEs and FALSEs to their numeric values 1 and 0 resp.
    Last edited by Tsjallie; 10-27-2014 at 05:52 PM.

+ 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. VBA code to turn off auto calc during a click and hold of a scrollbar
    By aallen1095 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-30-2012, 01:19 PM
  2. Missing Control Tab for Spinner Form?
    By BlueFortyTwo in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-10-2007, 12:11 AM
  3. [SOLVED] call a function on control click event
    By tkraju via OfficeKB.com in forum Excel General
    Replies: 4
    Last Post: 08-23-2006, 12:55 AM
  4. MouseMove & Click event over an image control
    By furbiuzzu in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-30-2006, 04:50 AM
  5. Why does the click event get control?
    By Lee Hunter in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-31-2005, 03: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