+ Reply to Thread
Results 1 to 8 of 8

Copy Rows That Match Variable Criteria And Paste To A New Worksheet

  1. #1
    Registered User
    Join Date
    03-15-2012
    Location
    Iowa
    MS-Off Ver
    Excel 2007
    Posts
    14

    Copy Rows That Match Variable Criteria And Paste To A New Worksheet

    I have a worksheet with various sales results. It is constantly updated and I use it to try and determine market trends. The only geographic identifier is area code so i would like to create a macro where i can type in multiple area codes into "sheet1" then have it search the area code column of the "sales results" sheet for each area code I am looking for. Then, when it finds one, to copy the entire row and move it to the "results" sheet.

    Does anyone have an idea of how to do this?
    Last edited by BrodyNoochie; 03-19-2012 at 04:18 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    02-09-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    1,055

    Re: Copy Rows That Match Variable Criteria And Paste To A New Worksheet

    Give some sample data...

  3. #3
    Registered User
    Join Date
    03-15-2012
    Location
    Iowa
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Copy Rows That Match Variable Criteria And Paste To A New Worksheet

    I have attached some sample data

    the AccountDetailReport is the general data
    the search tab is where I would like people to be able to enter their area codes and/or states (I currently have it set up as two seperate columns but if one column where they can enter area codes and states is easier, that would also work)
    The results tab would be where the search results are pasted
    In my attached example, someone would search for area codes 616, 216, and the state of CO and the results tab shows what I want the accounts the macro would end up with.

    My goal for the macro is to only search for matches in the area code and state columns (I wouldn't want an area code to by chance match a total sale amount and have the macro pull that account over). And when it finds a match, to copy and paste the entire row into the results tab.

    Thanks for the help
    Attached Files Attached Files

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Copy Rows That Match Variable Criteria And Paste To A New Worksheet

    Hi brodynoochie
    The code in the attached takes a different approach...see if it works for you.

    PS: well, it seems the file has some data (or something) it doesn't like...I'll see if I can fix that.
    Attached Files Attached Files
    Last edited by jaslake; 03-16-2012 at 05:08 PM.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  5. #5
    Valued Forum Contributor
    Join Date
    02-09-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    1,055

    Re: Copy Rows That Match Variable Criteria And Paste To A New Worksheet

    Hi..

    Try this macro..

    Sample Data.xlsm

  6. #6
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Copy Rows That Match Variable Criteria And Paste To A New Worksheet

    Hi brodynoochie
    This file seems to be better accepted
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    03-15-2012
    Location
    Iowa
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Copy Rows That Match Variable Criteria And Paste To A New Worksheet

    Many Thanks to you both. I haven't had a chance to try these out yet but as soon as I do, I will let you know how it goes. Hopefully it not only works but I am also bound to learn something. Thanks again!

  8. #8
    Registered User
    Join Date
    03-15-2012
    Location
    Iowa
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Copy Rows That Match Variable Criteria And Paste To A New Worksheet

    Both solutions offered worked. I think I will incorporate the logic of both of them into my sheet in one capacity or another. I just started toying with the code this afternoon and it has been working great. Thanks again

+ 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