+ Reply to Thread
Results 1 to 6 of 6

Search in two sheets, then copy matches to 3rd sheet

  1. #1
    Registered User
    Join Date
    05-12-2009
    Location
    Udevalla, Sweden
    MS-Off Ver
    Excel 2007
    Posts
    85

    Search in two sheets, then copy matches to 3rd sheet

    Hello.

    I have a Excel file with alot of data in it.
    I need a macro that will create a report for me and relive me from alot of manual work.


    The 1st sheet is named "Projects".
    This contains the search arguments.

    The 2nd sheet is named "Database".
    This is the sheet where I want to search in.

    The 3rd sheet is named "Report"
    This will contain the results of the search.


    So the going will be something like this:

    Copy row 7 from "Projects" into row 7 in "Report".
    Then use the value in that row, column E (named Search code).
    Search for rows that has this value in column E in the "Database" sheet.
    Copy all those rows to "Report" sheet.

    Copy row 8 from "Projects", leave two rows of space and paste into "Report".
    Repeat the procedure mentioned above..

    Repeat this until reaching a row in "Projects" that has no value in Column A.


    Does this make sense? I made an example Excel file which is attached.


    Any help on this is much appreciated
    Attached Files Attached Files
    Last edited by Carlsbergen; 09-25-2009 at 02:58 AM.

  2. #2
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628

    Re: Search in two sheets, then copy matches to 3rd sheet

    See macro in attached file (I've also added a command buttton in report sheet).

    Regards,
    Antonio
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    05-12-2009
    Location
    Udevalla, Sweden
    MS-Off Ver
    Excel 2007
    Posts
    85

    Re: Search in two sheets, then copy matches to 3rd sheet

    Quote Originally Posted by antoka05 View Post
    See macro in attached file (I've also added a command buttton in report sheet).

    Regards,
    Antonio

    Hi.. That seemed to work great!

    There was one problem though.
    I failed to mention that the list in the "Projects" sheet is very big, but I dont have to make a complete report every time. So what I do is that I use AutoFilter to select just one project at a time.
    However, the macro wants to do the whole list. Which is understandable given what I said in the original post.

    So, is there any way to have the macro just run through the rows that I filter out in "Projects"? I have "Freeze Panes" on in that sheet so is it possible to have the macro start at whatever row is below row 4 and the run through the filtered list?


    Many thanks so far. This seems very promising.


    EDIT 2: Nevermind this problem. I figured out a workaround. I made a second macro that copies the filtered
    list to another worksheet and modified the first macro to look for the search arguments there. Seems to work just fine.



    EDIT: Also, there was another problem.

    Lets say the search code is: 1ClubGDD234

    The macro will in this case also count: 21ClubGDD234
    as a match.

    Is there a way to avoid this?
    Last edited by Carlsbergen; 09-24-2009 at 03:30 AM.

  4. #4
    Registered User
    Join Date
    05-12-2009
    Location
    Udevalla, Sweden
    MS-Off Ver
    Excel 2007
    Posts
    85

    Re: Search in two sheets, then copy matches to 3rd sheet

    Any ideas?
    Im sooo close now to having it work perfectly

  5. #5
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628

    Re: Search in two sheets, then copy matches to 3rd sheet

    See attache file, I hope it can help.
    Please excuse me for my delay in answering.

    Regards,
    Antonio
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    05-12-2009
    Location
    Udevalla, Sweden
    MS-Off Ver
    Excel 2007
    Posts
    85

    Re: Search in two sheets, then copy matches to 3rd sheet

    Thank you antoka05!!
    Works like a charm!


+ 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