+ Reply to Thread
Results 1 to 7 of 7

Macro to copy and paste rows to a new sheet based on criteria

  1. #1
    Registered User
    Join Date
    05-27-2010
    Location
    Brisbane
    MS-Off Ver
    Excel 2003
    Posts
    6

    Macro to copy and paste rows to a new sheet based on criteria

    Hey guys,

    I have a workbook in which i have lots of different sheets with the same formatting, what i am trying to do is have a macro automatically copy and paste rows from these sheets to another sheet named "overdue payments" if they match a certain criteria.

    The criteria is in column K with the option of "Yes" or "No". I want the sheets to copy and paste if the answer is "No"

    also i would like this to automatically update when the answer is changed.

    I have attached a sample workbook for you to understand what i am talking about.

    I would really appreciate some help as i am now really stuck! i know it can be done but I'm just not sure how to write up the macro!!

    Thanks in advance
    Attached Files Attached Files
    Last edited by Belo; 05-31-2010 at 02:25 AM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro to copy and paste rows to a new sheet based on criteria

    This is pretty straightforward, but your workbook is in a big state of "No" values right now. So I think the best solution is to simply have the OVERDUE sheet collect up all the "No" rows (based on the NOTES column K) each time you activate the OVERDUE sheet.

    1) Right-click the OVERDUE sheet tab and select View Code
    2) Paste in this sheet event code:
    Please Login or Register  to view this content.

    3) Exit the VBEditor and save as a macro-enabled workbook.
    4) Now enter some "No" values in column K on the other sheets, then come back to the OVERDUE sheet and it will offer to update for you.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    05-27-2010
    Location
    Brisbane
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Macro to copy and paste rows to a new sheet based on criteria

    Thanks, I entered the code and it didnt come up as an error but it doesn't do anything? what am i doing wrong?

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro to copy and paste rows to a new sheet based on criteria

    Not sure, it works. I had to put a bunch of "NO" answers in column K since there were none in your sample sheet.

    Here's your sheet back, compare where I put the macro to where you did.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    05-27-2010
    Location
    Brisbane
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Macro to copy and paste rows to a new sheet based on criteria

    Thanks Heaps, I got it too work - the problem was just that there were a few differences between my sample and my actual sheet! =)

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro to copy and paste rows to a new sheet based on criteria

    If that takes care of your need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  7. #7
    Registered User
    Join Date
    05-27-2010
    Location
    Brisbane
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Macro to copy and paste rows to a new sheet based on criteria

    Just in the process - Thanks

+ 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