Consulting

Results 1 to 4 of 4

Thread: Problem between macro event and SpinButton

  1. #1

    Problem between macro event and SpinButton

    Hello,

    I have a SpinButton associated with an event macro.
    When I click on a cell that triggers the macro event, a SpinButton appears or not. If I press the SpinButton and I want to hide it by clicking on the cell, the SpinButton not necessarily disappear when clicking.
    Everything is explained on the sheet.

    Thank you for answer.SpinButton 10 (anglais).xlsm

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,729
    Location
    If I'm understanding, then adding the two marked lines <<<<<<<<<<<<<<<<<<< will re-hide the spin button after clicking


    Private Sub SpinButton1_SpinDown()
        Application.EnableEvents = False 'disable "Worksheet_Change"
        [C6] = resultado + SpinButton1.Value / 100
        [C5] = [Round(C1 * C3 * F1 / (C2 * F2 * (C6 + C3)),2)]
        MonBoSpin       '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        Application.EnableEvents = True 'activate "Worksheet_Change"
    End Sub
    '
    Private Sub SpinButton1_SpinUp()
        Application.EnableEvents = False 'disable "Worksheet_Change"
        [C6] = resultado + SpinButton1.Value / 100
        [C5] = [Round(C1 * C3 * F1 / (C2 * F2 * (C6 + C3)),2)]
        MonBoSpin       '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
        Application.EnableEvents = True 'activate "Worksheet_Change"
    End Sub
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  3. #3
    Hello Paul_Hossler,


    Thank you for your reply.
    I made the changes you have indicated. Unfortunately the problem persists. In addition to the conditional format of the cell "C6" only works one in two increments or decrements.
    I think the problem is that when you operate the SpinButton it is necessarily on an object and no cell of the sheet is selected.
    When operates the SpinButton and that we want to make it disappear, if you click on any cell in the sheet and then clicking on the cell "B", then yes the SpinButton disappears with one click.

  4. #4
    I finally solved the problem by adding:
    Private Sub SpinButton1_GotFocus()
        [C5].Select 'a cell must always be selected for the event macro cell-bound "B" is operational from 1st click on this cell
    End Sub
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •