+ Reply to Thread
Results 1 to 3 of 3

ComboBox auto next Items with time

Hybrid View

  1. #1
    Registered User
    Join Date
    06-03-2011
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    46

    ComboBox auto next Items with time

    Hello I have this Code for Auto Next Item in ComboBox, sometimes I need to swear Repeat 10 times this code, but sometimes with more than 10 times, and to do this should make 10 times Past the same coding, or if I need them with little I have to delete one by one code.

    Is there any chance that repeated code as many times as is the Value of textbox 1, example if Textbox1.Value is "7" Times, code is repeated 7 times

    
    Private Sub CommandButton10_Click()
    
    Dim idx As Long
    idx = ComboBox3.ListIndex
    If idx <> ComboBox3.ListCount - 1 Then
    ComboBox3.ListIndex = idx + 1
    Else
    ComboBox3.ListIndex = 0
    End If
    
    Application.Wait (Now + TimeValue("0:00:5"))
    
    
    idx = ComboBox3.ListIndex
    If idx <> ComboBox3.ListCount - 1 Then
    ComboBox3.ListIndex = idx + 1
    Else
    ComboBox3.ListIndex = 0
    End If
    
    Application.Wait (Now + TimeValue("0:00:5"))
    
    idx = ComboBox3.ListIndex
    If idx <> ComboBox3.ListCount - 1 Then
    ComboBox3.ListIndex = idx + 1
    Else
    ComboBox3.ListIndex = 0
    End If
    
    Application.Wait (Now + TimeValue("0:00:5"))
    
    idx = ComboBox3.ListIndex
    If idx <> ComboBox3.ListCount - 1 Then
    ComboBox3.ListIndex = idx + 1
    Else
    ComboBox3.ListIndex = 0
    End If
    
    Application.Wait (Now + TimeValue("0:00:5"))
    
    End Sub
    Last edited by johan12; 04-15-2013 at 02:59 PM.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: ComboBox auto next Items with time

    Try something like this...

    Private Sub CommandButton10_Click()
        
        Dim i    As Long
        
        For i = 1 To TextBox1.Value
        
            With ComboBox3
                If .ListIndex = .ListCount - 1 Then
                    .ListIndex = 0
                Else
                    .ListIndex = .ListIndex + 1
                End If
            End With
            
            Me.Repaint
            Application.Wait (Now + TimeValue("0:00:5"))
            
        Next i
        
    End Sub

  3. #3
    Registered User
    Join Date
    06-03-2011
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    46

    Re: ComboBox auto next Items with time

    AlphaFrog Thanks it is Work Prefect. Thank You A lot.

+ 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