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




Reply With Quote
Bookmarks