+ Reply to Thread
Results 1 to 7 of 7

Spin button controlling multiple cells???

Hybrid View

  1. #1
    Registered User
    Join Date
    05-01-2015
    Location
    Caerphilly, Wales
    MS-Off Ver
    2003, 2013
    Posts
    4

    Spin button controlling multiple cells???

    Hi I need to have one spin button to control multiple cells of my choice i.e. the one selected, rather than use 100+ spin buttons. Is this possible???

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Spin button controlling multiple cells???

    Don't think you can... but could you not make all the other cells equal the cell the spin button is linked to? For example make the spin button control A1, and then "=A1" in all the other cells?
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Spin button controlling multiple cells???

    Oh oops, you mean control only the active cell?

  4. #4
    Registered User
    Join Date
    05-01-2015
    Location
    Caerphilly, Wales
    MS-Off Ver
    2003, 2013
    Posts
    4

    Re: Spin button controlling multiple cells???

    Yes I want the spin button to only control the active cell

  5. #5
    Registered User
    Join Date
    05-01-2015
    Location
    Caerphilly, Wales
    MS-Off Ver
    2003, 2013
    Posts
    4

    Re: Spin button controlling multiple cells???

    Yes I want the spin button to only control the active cell
    Last edited by ieuandavies; 05-01-2015 at 01:34 PM.

  6. #6
    Registered User
    Join Date
    05-01-2015
    Location
    Caerphilly, Wales
    MS-Off Ver
    2003, 2013
    Posts
    4

    Re: Spin button controlling multiple cells???

    SOLVED!!! I type my own code for the sheet and now its working fine, thanks for the help anyway

  7. #7
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Spin button controlling multiple cells???

    Hi,

    See the following code (using a Forms Spinbutton which is included in the attached file.

    In an ordinary code module such as Module1:
    Option Explicit
    
    Public vGblOldSpinButtonValue As Variant
    
    Sub FormsSpinButtonControlActiveCell()
    
      Dim vValue As Variant
      
      Dim iMaximumSpinButtonValue As Long
      Dim iMinimumSpinButtonValue As Long
      Dim iSpinButtonValue As Long
    
      Dim sControlName As String
      Dim sLinkedCell As String
      
      'Get the name of the SpinButton Control that was activated
      'Exit if this routine is not called by a SpinButton Click
      On Error Resume Next
      sControlName = Application.Caller
      If Err.Number <> 0 Then
        Err.Clear
        On Error GoTo 0
        Exit Sub     'Exit if this routine is not called by a SpinButton Click
      End If
      On Error GoTo 0
      
      'Get the current SpinButton attributes
      iSpinButtonValue = ActiveSheet.Shapes(sControlName).ControlFormat.Value
      iMinimumSpinButtonValue = ActiveSheet.Shapes(sControlName).ControlFormat.Min
      iMaximumSpinButtonValue = ActiveSheet.Shapes(sControlName).ControlFormat.Max
      sLinkedCell = ActiveSheet.Shapes(sControlName).ControlFormat.LinkedCell
      
      'Initialize the SAVED 'SpinButton' Value on the First 'SpinButton' Click
      If Len(vGblOldSpinButtonValue) = 0 Then
        MsgBox "Initializing SpinButton SAVED Value." & vbCrLf & _
               "The last SpinButton 'Click' was NOT PROCESSED."
        vGblOldSpinButtonValue = iSpinButtonValue
        Exit Sub
      End If
      
      'Debug.Print
      'Debug.Print ActiveSheet.Shapes(sControlName).Name
      'Debug.Print ActiveSheet.Shapes(sControlName).ControlFormat.Value
      'Debug.Print ActiveSheet.Shapes(sControlName).ControlFormat.Min
      'Debug.Print ActiveSheet.Shapes(sControlName).ControlFormat.Max
      
      'Get the value of the Active Cell
      'If it is a NUMBER, increment or decrement as required
      vValue = ActiveCell.Value
      If IsNumeric(vValue) Then
        If iSpinButtonValue > vGblOldSpinButtonValue Then
          vValue = vValue + 1
        Else
          vValue = vValue - 1
        End If
        ActiveCell.Value = vValue
      End If
    
      'Reset The SpinButton Value to the Middle of the Range if it is at MINIMUM or MAXIMUM
      If iSpinButtonValue = iMinimumSpinButtonValue Or iSpinButtonValue = iMaximumSpinButtonValue Then
        iSpinButtonValue = (iMinimumSpinButtonValue + iMaximumSpinButtonValue) / 2
        ActiveSheet.Range(sLinkedCell).Value = iSpinButtonValue - 1
      End If
      
      'Save the Current 'SpinButton' value for comparison purposes on the next Pass
      vGblOldSpinButtonValue = iSpinButtonValue
      
    End Sub
    Lewis

+ 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. [SOLVED] Help with Spin Button. Set Spin button starting value based on a text box value
    By etuckram in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-18-2014, 10:05 AM
  2. [SOLVED] Spin Button Using Multiple Active Cells
    By JaysonP in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-12-2014, 11:00 PM
  3. spin button: create multiple cell link
    By DavidRoger in forum Excel General
    Replies: 5
    Last Post: 04-30-2014, 05:44 AM
  4. Spin Button:spin cells A7
    By ice in forum Excel General
    Replies: 1
    Last Post: 03-16-2007, 02:23 PM
  5. Controlling an ActiveX Spin Button
    By d.stephanou@gmail.com in forum Excel General
    Replies: 5
    Last Post: 04-23-2006, 08:00 AM

Tags for this Thread

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