+ Reply to Thread
Results 1 to 6 of 6

Thread: Form Spinner, up or down pressed?

  1. #1
    Registered User
    Join Date
    07-04-2009
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    3

    Form Spinner, up or down pressed?

    Using Excel 2007 Form Spinners (i.e. not ActiveX ones) how can I detect whether the user has pressed the up or the down button? I can get the associated value of it, but I would like to use the control independent from the actual spinner. In other words, I have various spinners on my sheet and would like cells to move up or down (not incremental, through specific vba code instead) depending on which spinners is pressed and in which direction.
    I can happily identify the spinners through ActiveSheet.Spinners(Application.Caller).TopLeftCell.Row (and .Column), but the value property is capped through Min and Max settings, so this doesnt necessarily tell me which direction the user pressed it.
    Thanks for any clues in advance

  2. #2
    Forum Guru shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007, 2010
    Posts
    25,736

    Re: Form Spinner, up or down pressed?

    Wouldn't it be easier to use ActiveX spin buttons?
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    2003 & 2007 & 2010
    Posts
    11,335

    Re: Form Spinner, up or down pressed?

    Min value=0
    Max value=1

    Sub Spinner2_Change()
    
        With ActiveSheet.Shapes(Application.Caller)
            If .ControlFormat.Value = 1 Then
                MsgBox "Up"
            Else
                MsgBox "Down"
            End If
        End With
            
    End Sub
    Cheers
    Andy
    www.andypope.info

  4. #4
    Registered User
    Join Date
    07-04-2009
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Form Spinner, up or down pressed?

    Many Thanks for your replies.

    The last one worked well (just setting Min=0 and Max=1, therefore knowing what was pressed).

    Two related follow ups

    1. Would it have been easier using ActiveX version (i.e. first reply) and if so how?

    2. For a spin button on a pop-up form, how can I do the same thing? There I only tend to get SpinButton1_Change which cant be tricked with the 0/1. (If its 0 already, then pressing down doesnt trigger the event). I was thinking of having min=0, max=2 and always setting it to 1 at the end of it, but this itself triggers another call to SpinButton1_Change. Is this the way forward (if yes, how do I disable this recursive calling) or is there a better way?

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    2003 & 2007 & 2010
    Posts
    11,335

    Re: Form Spinner, up or down pressed?

    On a userform use SpinUp and SpinDown events.

    ActiveX also has these 2 events, which would have made it easier.
    Cheers
    Andy
    www.andypope.info

  6. #6
    Registered User
    Join Date
    07-04-2009
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Form Spinner, up or down pressed?

    Thanks, they work fine there. Reason why I didnt use them for the sheet was that I had hundreds of spin buttons. From what I gather the ActiveX ones automatically link to Spin253_SpinUp etc., so I would have a huge number of those functions. Using the other ones I can link them all to one user defined function where I identify the object through Application Caller.

+ 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.2.0