Results 1 to 6 of 6

UserForm: jump to the position of selected result from listbox

Threaded View

  1. #1
    Forum Contributor
    Join Date
    11-12-2007
    Location
    Germany
    MS-Off Ver
    2007
    Posts
    472

    UserForm: jump to the position of selected result from listbox

    Hallo everyone,

    I have a userform which has a textbox "txtSearchString". When I type a string in it and click Button "cmdSearch", it looks for the typed word in all worksheets and shows me the results in a Listbox "lstResults".

    Now I want to select one of the results and jump to that cell (which contains the selected result from Listbox) by clicking the button "makeResultActive".

    I will be thankful if someone could help me in writing code for the button "makeResultActive".

    I already have two other buttons for other puposes which do their job well. Now I need code for the next button "makeResultActive".

     
    Private Sub CommandButton3_Click()
    'this Button copys the selected result from the resultlist of listbox "lstResults"
        Dim i As Integer
        Dim LR As Long
        
        LR = Sheets("de-ps").Range("A" & Rows.Count).End(xlUp).Row + 1
        
        With lstResults
            For i = 0 To .ListCount - 1
                If .Selected(i) Then
                    Sheets("de-ps").Range("A" & LR).Value = .List(i)
                    
                    LR = LR + 1
                End If
            Next i
        End With
    End Sub
     
     
    Private Sub CommandButton4_Click()
    ' this Button replaces content of active Cell through selected result from lstResults
    
        Dim i As Integer
        Dim LR As Long
        
       
        With lstResults
            For i = 0 To .ListCount - 1
                If .Selected(i) Then
                    ActiveCell.Value = Me.lstResults.Value
                    'Sheets("de-ps").Range("A" & LR).Value = .List(i)
                    
                    LR = LR + 1
                End If
            Next i
        End With
    End Sub
    
     
    Private Sub makeResultActive_Click()
    'when clicked it should make cell of selected result from lstResults active/jumb there
     
     
    End Sub
    Thanks for each help in advance.
    Last edited by wali; 11-17-2011 at 02:45 PM.

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