find a row in a worksheet

Important Notice

Please note that on 14th December 2023 users will experience an expected outage whilst we make upgrades to our network. We anticipate this process may take a couple of hours and so we apologise in advance for any inconvenience.

  • How do i use vba code to find a row in a worksheet using listbox index(0) on button click and make the row active?

    Worksheet Column A matches listbox index(0) value

    • Best Answer

    Your description is very generic so it is not possible to give you code that you can simply plug in.

    Where is the ListBox? What is its name? If on a worksheet, is it ActiveX or Forms?
    Where is the button? What is its name? If on a worksheet, is it ActiveX or Forms?
    What worksheet has the value you want to make active?

    Is that worksheet active when you click the button

    Something like this:


    Making the world a better place one fret at a time | | |·| |·| |·| |·| | |:| | |·| |·|

  • 6stringJazzer... this works exaclty like I wanted it to! Thank you very much!

    Second part of this and I will try to be a little more specific.

    The command button executes the code you've provided. I just changed to suit my needs as far as the name of sheet...yaddi yadda.

    under the same command the end of this sub... This userform is my Customer Order Form

    On initialize I have:


    but nothing happens

    Background on this: Userform 1 is my Customer Activity Center

    The listbox has several customers in it. When a customer emails an order... i want to scroll through and find the customer to process the order for.

    These customers are identified within this database by their CUSTOMER ID which is the value of the listbox listindex(0) AND the cell value in range ("A") in the worksheet. I thought if someone helped me such as you have with the code to select the cell in range. Then it should be easy to have the cell value go to textbox14 but it has and is evading me. What I want to do is fill Textbox 14 with the value from range A, text box 15 with range B same row, etc., all the way to textbox19 referencing each value in columns A,B,C,D,E. Any help whatsoever? And again, thank you for taking the time for the help with the other code!!

  • Using ActiveCell is usually not a good idea because the code may not have control over what cell is active. What exactly are you trying to do there?


    Making the world a better place one fret at a time | | |·| |·| |·| |·| | |:| | |·| |·|

  • sorry just saw your reply... been a very busy time for me.

    I just need the cell value that has been selected during the subroutine from clicking the command button to be the value that populates textbox14.

    the command button is on userform2

    textbox14 is on userform3.

    selected cell is found by the value in listbx listindex(0). the command button activates worksheet("customers"))...goes through range (A:A) until found, this is the code you suggested to me and it works perfect. Also in the code under the command button it opens my userform3 and upon initliazing I am needing textbox14 to be populated with the selected cells value. I have other textboxes as well but figured once i could figure this part out, i could have the others filled by using the offset.

    I hope this gives you enough insight.

    Thanks for any help.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!