+ Reply to Thread
Results 1 to 3 of 3

Double Click Spin Button

Hybrid View

adam2308 Double Click Spin Button 10-27-2012, 03:55 AM
Andy Pope Re: Double Click Spin Button 10-27-2012, 05:26 AM
adam2308 Re: Double Click Spin Button 10-27-2012, 02:40 PM
  1. #1
    Forum Contributor
    Join Date
    02-20-2009
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    467

    Double Click Spin Button

    I have a Spin Button on a worksheet that increases/decreases the value in the cell of the active row of column L by 0.01.

    Can I add some code to this Spin Buttton where if I double click the control (up or down) it triggers the code below?

    Cells(ActiveCell.Row, "L").Value = Cells(ActiveCell.Row, "AA").Value
    Last edited by adam2308; 10-27-2012 at 02:40 PM.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Double Click Spin Button

    Spin button does not have a double click event.

    You could make use of the Shift key is the spin button is an ActiveX control.

    right click worksheet tab and use this code.

    Private m_blnShiftDown As Boolean
    Private Sub SpinButton1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    
        If Shift Then
            m_blnShiftDown = True
        End If
        
    End Sub
    
    Private Sub SpinButton1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    
        m_blnShiftDown = False
        
    End Sub
    
    
    Private Sub SpinButton1_SpinDown()
    
        If m_blnShiftDown Then
            Cells(ActiveCell.Row, "L").Value = Cells(ActiveCell.Row, "AA").Value
        Else
            Cells(ActiveCell.Row, "L").Value = Cells(ActiveCell.Row, "L").Value - 1
        End If
    
    End Sub
    
    
    Private Sub SpinButton1_SpinUp()
    
        If m_blnShiftDown Then
            Cells(ActiveCell.Row, "L").Value = Cells(ActiveCell.Row, "AA").Value
        Else
            Cells(ActiveCell.Row, "L").Value = Cells(ActiveCell.Row, "L").Value + 1
        End If
    
    End Sub
    Cheers
    Andy
    www.andypope.info

  3. #3
    Forum Contributor
    Join Date
    02-20-2009
    Location
    Manchester, England
    MS-Off Ver
    Excel 2007
    Posts
    467

    Re: Double Click Spin Button

    I didn't think there was a double click event (just checking). The shift key alternative was a good suggestion though. Cheers!

+ 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.6.0 RC 1