Welcome to the Excel Forum

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed.

Please Register to Remove these Ads

Please Register to Remove these Ads



Reply
  #1  
Old 07-04-2009, 08:17 AM
catch catch is offline
Registered User
 
Join Date: 04 Jul 2009
Location: England
MS Office Version:Excel 2007
Posts: 3
catch is becoming part of the community
Form Spinner, up or down pressed?

Please Register to Remove these Ads

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
Reply With Quote
  #2  
Old 07-04-2009, 01:08 PM
shg's Avatar
shg shg is offline
Forum Guru
 
Join Date: 20 Jun 2007
Location: The Great State of Texas
MS Office Version:2003, 2007
Posts: 18,505
shg makes giving solutions look like childsplay shg makes giving solutions look like childsplay shg makes giving solutions look like childsplay shg makes giving solutions look like childsplay shg makes giving solutions look like childsplay shg makes giving solutions look like childsplay shg makes giving solutions look like childsplay shg makes giving solutions look like childsplay shg makes giving solutions look like childsplay shg makes giving solutions look like childsplay
Re: Form Spinner, up or down pressed?

Wouldn't it be easier to use ActiveX spin buttons?
__________________
Entia non sunt multiplicanda sine necessitate.
Reply With Quote
  #3  
Old 07-04-2009, 02:41 PM
Andy Pope's Avatar
Andy Pope Andy Pope is offline
Forum Guru
 
Join Date: 10 May 2004
Location: Essex, UK
MS Office Version:2003 & 2007 sp2
Posts: 7,223
Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding
Re: Form Spinner, up or down pressed?

Min value=0
Max value=1

Code:
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
Reply With Quote
  #4  
Old 07-08-2009, 11:49 AM
catch catch is offline
Registered User
 
Join Date: 04 Jul 2009
Location: England
MS Office Version:Excel 2007
Posts: 3
catch is becoming part of the community
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?
Reply With Quote
  #5  
Old 07-08-2009, 12:06 PM
Andy Pope's Avatar
Andy Pope Andy Pope is offline
Forum Guru
 
Join Date: 10 May 2004
Location: Essex, UK
MS Office Version:2003 & 2007 sp2
Posts: 7,223
Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding Andy Pope Has a higher level of understanding
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
Reply With Quote
  #6  
Old 07-09-2009, 04:46 AM
catch catch is offline
Registered User
 
Join Date: 04 Jul 2009
Location: England
MS Office Version:Excel 2007
Posts: 3
catch is becoming part of the community
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 With Quote


Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Forum Jump