Consulting

Results 1 to 5 of 5

Thread: Goto a specific part of a list

  1. #1
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location

    Goto a specific part of a list

    I have a userform with a scroll bar that allows the user to scrool to the row they want. Potentially there will be thousands of rows of data. Is there a way to jump to a specific part of the list say the ones starting with "G"? Thanks
    Peace of mind is found in some of the strangest places.

  2. #2
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location

    search textbox

    austenr,
    I may be wrong but I think you can add a textbox(textbox2 in my example) and use this code on it:

    Private Sub TextBox2_Change() 
    Dim Search          As String
        Dim n               As Long
        Dim i               As Long
        Dim j               As Long
    Search = Me.TextBox2.Text
        n = Len(Me.TextBox2)
        j = Me.lstSelection.ListCount - 1
        For i = 0 To j
            If Left(Me.lstSelection.List(i), n) = Search Then
                Me.lstSelection.Selected(i) = True
                Exit For
            End If
        Next
    End Sub

    lstSelection is the name of your listbox. change those two things to match your listbox and textbox. then when you type the first letter in the search(textbox) it will go there immediatly. Works for me
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  3. #3
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    Thaks that worked great!!
    Peace of mind is found in some of the strangest places.

  4. #4
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Your Welcome,
    Glad it works as well for you as it did for me.
    Thats one of many I have pilfered from this forum in the past.
    You can mark this one solved then?
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  5. #5
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    yep
    Peace of mind is found in some of the strangest places.

Posting Permissions

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