Results 1 to 8 of 8

Thread: Custom Spin Button Based On Values Passed From Array

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,401
    Rep Power
    10

    Spin Button Based On Values Passed From Array

    Code:
    Option Explicit
    Option Base 1
    Private Enum LeftOrRight
        LeftMove = 0
        RightMove = 1
    End Enum
    Dim arr As Variant
    Dim lngCurrentBound As Long
    Sub CusSpin()
    
        If Not IsArray(arr) Then
            arr = Array("Txt1", "Txt2", "Txt3", "Txt4", "Txt5", "Txt6", "Txt7", "Txt8", "Txt9", "Txt10", "Txt11", "Txt12")
            lngCurrentBound = LBound(arr)
        End If
        If Application.Caller = "btnLeft" Then
            Cells(1, 2).Value = MoveValue(LeftMove)
        Else
            Cells(1, 2).Value = MoveValue(RightMove)
        End If
        
    End Sub
    
    Private Function MoveValue(lngLeftOrRight As LeftOrRight)
    
        If lngLeftOrRight Then
            lngCurrentBound = (lngCurrentBound) Mod UBound(arr) + 1
        Else
            lngCurrentBound = (lngCurrentBound - 1) Mod UBound(arr) + (UBound(arr) * Abs((lngCurrentBound - 1) = 0))
        End If
        
        MoveValue = arr(lngCurrentBound)
        
    End Function
    Attached Files Attached Files
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

Similar Threads

  1. Replies: 14
    Last Post: 01-26-2013, 04:58 AM
  2. Replies: 1
    Last Post: 12-04-2012, 08:56 AM
  3. counting consecutive values in an array
    By 5ko in forum Excel Help
    Replies: 3
    Last Post: 12-04-2012, 03:49 AM
  4. Formula to Display Month and Dates Using Spin Button
    By ayazgreat in forum Excel Help
    Replies: 6
    Last Post: 11-21-2012, 10:19 PM
  5. Subtraction Of Series Of Cells' / Array Values
    By PcMax in forum Excel Help
    Replies: 6
    Last Post: 10-26-2012, 11:55 PM

Posting Permissions

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