+ Reply to Thread
Results 1 to 4 of 4

Copy rows to different sheet in condition is met

  1. #1
    Registered User
    Join Date
    10-05-2015
    Location
    Peterborough
    MS-Off Ver
    2007
    Posts
    5

    Copy rows to different sheet in condition is met

    Good afternoon,

    I'm in need to a little help if possible. I have a worksheet that has names down column A8:A41. There are other columns below that are working some things out for me, but I don't need that copied. In the cells (B7:F7) there are different headings - SE, EA, PP, LA, HA.

    What I need is a way to copy an entire row depending on what I enter in the columnss below those headings. For instance, if for the first person (name in cell A8) I enter Y in cell B8, I want the entire row to copy to worksheet 2. This worksheet 2 also has the same headings and set up. All looks the same, but it is blank at the moment.

    So there might only be 3 rows that have Y entered in the SE column - I'd want them to fill up at the top of the worksheet 2 - as opposed to their row they're in on sheet 1.

    I'd want to do this for the other headings as well.

    As an extra, if no 'Y' is entered, I'd want those rows that are left blank to copy to a different worksheet.

    I guess this would be a VBA, but I'm not very good at creating these yet. I hope I explained myself (probably not). If anyone can help or point me in the right direction, I'd be very appreciative.

  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: Copy rows to different sheet in condition is met

    This CAN be done for a such a short range using Formulas.

    1) Sheet2 should have an extra column where you can only use the array formula once per row to flag a row on sheet1 as pertinent. Then that row number is used to fill in the rest of the fields on that row for you using a normal INDEX/MATCH.

    2) Attach a sample workbook. Make sure there is just enough data to demonstrate your need. IMake sure your desired results are shown, mock them up manually from this sample data so it's visually clear.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic
    _________________
    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
    10-05-2015
    Location
    Peterborough
    MS-Off Ver
    2007
    Posts
    5

    Re: Copy rows to different sheet in condition is met

    Here is a sample of what I'm thinking.

    I have done the first few sheets. The others will follow the same idea. Hope it makes sense. If there is a Y in the column - I want the row copied to the corresponding sheet. If there isn't, then there is a 'non' sheet I want those names on.
    Attached Files Attached Files

  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: Copy rows to different sheet in condition is met

    1) A key array formula in AF8 collects the index position of matching rows.
    =IFERROR(SMALL(IF(Sheet1!$B$8:$B$41="Y", ROW(Sheet1!$B$8:$B$41)-7, ""), ROW(A1)), "")
    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.

    2) Copy AF8 down through AF41 to complete the array.

    3) The formula in A8 is:
    =IF(ISNUMBER($AF8), INDEX(Sheet1!A$8:A$41, $AF8)&"", "")

    3) Copy A8 down and across the table to all needed cells.

    SE is now complete.

    4) Copy A7:AF41 and paste it over NON-SE at cell A7

    5) Edit the "Y" in the AF8 formula to "", then copy AF8 down.

    NON-SE is now complete.


    Repeat ad nauseum.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Copy rows from active sheet to another sheet (last row) if condition in column X is met
    By mortless in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-17-2013, 08:11 AM
  2. Copy rows in a new sheet with a condition
    By Brett Mercier in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-23-2013, 11:07 AM
  3. macro to copy rows to another sheet based on condition mentioned in another workbook
    By sona_tejas in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-07-2013, 06:23 AM
  4. [SOLVED] Copy of rows from one sheet to other depend of condition in one cell
    By maksa1982 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-02-2012, 06:19 PM
  5. Copy rows from one sheet to another,while deleting from source,under condition
    By piulibero in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-14-2011, 04:35 AM
  6. Macro to Copy Rows with Certain Condition to another Sheet?
    By rorybecers in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-24-2011, 09:15 AM
  7. Copy rows from a master sheet based on condition
    By Rohun Heesen in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-13-2011, 08:33 PM
  8. [SOLVED] Copy entire rows matching condition to a new sheet
    By JP in forum Excel General
    Replies: 3
    Last Post: 05-20-2005, 07:06 PM

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