Find method: using one range to search for all occurences in another

  • Hello All:


    I trying to use the find method with two ranges. My objective is to locate all occurences of the values of range 1 in range 2. My macro finds all the values, however, it loops to many times. Here is a copy of my code. Any help with this problem will be greatly appreciated.


    TIA,
    Chris


  • Re: Find method: using one range to search for all occurences in another


    Your two tests on foundcell (one for nothing and one if its row is before the previously foun rows) should be put immediately after the Find and FindNext lines rather than after all the updating with foundcell's offsets has been done.

  • Re: Find method: using one range to search for all occurences in another


    I'm not sure if I've digested your code completed correctly, but it seems that you could shorten it quite a bit by using .COPY (with PASTE SPECIAL if your data has formulas in it). If your has not formulas, the code shortens further to a single line for each copy paste in the syntax of

    Code
    GetRange.Copy PutRange


    Anyway, here is an example to play with.

  • Re: Find method: using one range to search for all occurences in another


    Thanks Guys!


    I"ve been having a fit with this. And it seems the more I fiddled with this the more that it deteriorated. I will try both suggestion and let you know they turn out.


    Thanks Again,
    Chris

Participate now!

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