Adjust Search Macro to Search Across Multiple Sheets

  • Hi Guys


    I have this macro (as per below) that I use to 'locate' a "Ref Number" within another sheet. I would like the macro to be able to search multiple sheets;


    If it finds the result in 1st sheet it stops (as it does now).
    If it doesn't find in 1st sheet, it goes to 2nd sheet and continues, if it doesn't find in 2nd sheet it goes to 3rd sheet and continues.





    I don't know how to do the code myself, any assistance much appreciated.
    Thanks Rob

  • Re: Adjust Search Macro to Search Across Multiple Sheets


    Try this:


    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • Re: Adjust Search Macro to Search Across Multiple Sheets


    Thank you for your speedy reply. I need to be able to specify in the code which sheets I need it to search?
    I now suspect I wasn't quite specific enough in which case please accept my sincere apologies, I don't want to waste anyone's time. I was trying to be concise without any excess wording...

  • Re: Adjust Search Macro to Search Across Multiple Sheets


    Try this



    Obviously the sheet names above are just examples and should be replaced with actual sheet names!


    If you only have a few sheets NOT to be searched and many that DO need to be searched then it may be easier to use this


    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • Re: Adjust Search Macro to Search Across Multiple Sheets


    Hi, thanks.


    I've put 3 of my sheet names in, when run it throws up an error?


    [ATTACH=CONFIG]70904[/ATTACH]


  • Re: Adjust Search Macro to Search Across Multiple Sheets


    Change

    Code
    Application.GoTo ws.r


    to

    Code
    ws.Activate: r.Activate

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • Re: Adjust Search Macro to Search Across Multiple Sheets


    Hi


    I tried this and I can't see anything happen? Also, I tested with a 'known result' and it didn't select the field in the sheet?


    Thank you

  • Re: Adjust Search Macro to Search Across Multiple Sheets


    Put this in the Worksheet Object Module for the sheet which has the values to be searched for, then, rather that just selecting the cell containing the value to be searched for, double click that cell.



    See the attached file to see it working.

  • Re: Adjust Search Macro to Search Across Multiple Sheets


    When you enter your actual sheet names to be searched make sure that each is an exact replica of the sheet name, it is case sensitive. Also check that none of the actual sheet names have leading or trailing spaces.

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • Re: Adjust Search Macro to Search Across Multiple Sheets


    You're welcome.

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

Participate now!

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