+ Reply to Thread
Results 1 to 6 of 6

UserForm: jump to the position of selected result from listbox

  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".

    Please Login or Register  to view this content.
    Thanks for each help in advance.
    Last edited by wali; 11-17-2011 at 02:45 PM.

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: UserForm: jump to the position of selected result from listbox

    wali,

    Attached is an example workbook. It contains a macro that can be run with keyboard shortcut: Ctrl+Shift+F Using the macro will launch a userform that has a textbox that you type search criteria into, and then press Search. The results will populate the listbox. Clicking on an item in the listbox will cause that item's worksheet and cell to be selected.

    Hopefully, you'll be able to use the example and apply what you need to your own workbook.
    Attached Files Attached Files
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: UserForm: jump to the position of selected result from listbox

    wali,

    From the Forum Rules:

    4. Don't Private Message or email questions to moderators or other members. The point of having a public forum is to share solutions to common (and sometimes uncommon) problems with all members.

    Quote Originally Posted by wali
    Hello,
    thank you very much for you help in my thread:

    http://www.excelforum.com/excel-prog...ml#post2644305

    I am sorry for not being clear enough with my problem description. The fact is that I already have a userform and all i need is a new button "makeResultActive"in it.

    I will be very gratefull if you could find time and have a look at it once again. You can download my excel file from:

    www.qamosona.de/downloads/Userform-wali.xls

    Thank you very much.


    I took a look at your file, and got the makeResultActive button working. Had to make a couple of changes to cmdSearch_Click():
    Please Login or Register  to view this content.


    And here's the code for makeResultActive_Click()
    Please Login or Register  to view this content.

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

    Re: UserForm: jump to the position of selected result from listbox

    Hi tigeravatar,

    thank you very much for the modification. Unfortunately it shows me an error when i run my userform. It shows error in


    Please Login or Register  to view this content.

    I am attaching the excelform with you new code, so that you can try it. For example type "40" in searchform and click on "<= search" button. When the results are shown select any result and click on button "makeResultActive". An error accurs then
    Attached Files Attached Files

  5. #5
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: UserForm: jump to the position of selected result from listbox

    wali,

    You got an error because you didn't update cmdSearch_Click(). All I did was replace the existing cmdSearch_Click() code with the cmSearch_Click() code I provided in the earlier post and it started working correctly without error.
    Attached Files Attached Files

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

    Re: UserForm: jump to the position of selected result from listbox

    Woow! it works. Thank you very much. Thanks a million times.

    God bless you.

+ 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