Closed Thread
Results 1 to 6 of 6

Help moving table contents from one sheet to another depending on criteria

Hybrid View

  1. #1
    Registered User
    Join Date
    03-11-2022
    Location
    London, England
    MS-Off Ver
    Professional Plus 2016
    Posts
    15

    Help moving table contents from one sheet to another depending on criteria

    Hi all,

    Can anyone please help with some code that will allow me to move data from one work sheet to a specific location on another sheet, depending on a cell criteria?

    In the attached simplified example I have a table in Sheet1 with 4 columns, titled; Name (A1), On (B1), Off (C1) and a drop down menu with the choice of yes or no (D1).

    I am wanting to transfer any data in the rows of the first 3 columns of this table to different locations on Sheet2 depending on the value selected in D1 on Sheet1.

    For example

    If Sheet1 D2 = Yes, than I want to copy Sheet1 A2:C2 to Sheet2 B3:D3
    If Sheet1 D3 = No, then I want to copy Sheet1 A3:C3 to Sheet2 F3:H3

    I hope that makes sense.. I would be very appreciative if anyone was able to assist with some advice on the best way to perform this please

    Thank you again.
    Attached Files Attached Files

  2. #2
    Forum Expert dosydos's Avatar
    Join Date
    12-09-2015
    Location
    MA, USA
    MS-Off Ver
    365(PC) V:2412
    Posts
    1,477

    Re: Help moving table contents from one sheet to another depending on criteria

    I would Suggest utilizing the FILTER function.
    See the attached file/
    First thing i would do is on SHeet 2 delete the tables.
    I would then would then put your headers at the top as text.
    Then in cell B3 i put the formula:
    Formula: copy to clipboard
    =FILTER(Sheet1!$A$2:$C$19,Sheet1!$D$2:$D$19="Yes")


    In cell F3 i used the formula:
    Formula: copy to clipboard
    =FILTER(Sheet1!$A$2:$C$19,Sheet1!$D$2:$D$19="No")


    the formula will spill automatically and return all rows with yes and No accordingly
    Attached Files Attached Files
    <----- If you are happy with your solution please click on the "* Add Reputation" as a way to say thank you.

  3. #3
    Registered User
    Join Date
    03-11-2022
    Location
    London, England
    MS-Off Ver
    Professional Plus 2016
    Posts
    15

    Re: Help moving table contents from one sheet to another depending on criteria

    Thank you for your reply but when I attempt to use this or add to the table I am getting #NAME? as the output... Could this be because I am currently using Office Professional Plus 2016 and not 365?

    Do you have any other ideas or suggestions to correct this?

    Thank you again for your help

  4. #4
    Forum Expert dosydos's Avatar
    Join Date
    12-09-2015
    Location
    MA, USA
    MS-Off Ver
    365(PC) V:2412
    Posts
    1,477

    Re: Help moving table contents from one sheet to another depending on criteria

    I could have sworn your version said "365" when I posted that. Unfortunately 2016 doesn't support FILTER function. You would need either 2021 or 365.
    As for a fix using the below formulas are array formulas so you must use CTRL + SHIFT + ENTER when entering the formula. If done correctly { } will be inserted around the formula automatically:

    in cell B3:
    Formula: copy to clipboard
    =IFERROR(INDEX(Sheet1!A$1:A$19,SMALL(IF(Sheet1!$D$2:$D$19="Yes",ROW(Sheet1!$D$2:$D$19),""),ROW(1:1))),"")

    Drag over to column D and then drag down as much as you want.

    In cell F3
    Formula: copy to clipboard
    =IFERROR(INDEX(Sheet1!A$1:A$19,SMALL(IF(Sheet1!$D$2:$D$19="No",ROW(Sheet1!$D$2:$D$19),""),ROW(1:1))),"")

    Drag over to column H and then drag down as much as you want.
    Attached Files Attached Files
    Last edited by dosydos; 03-18-2022 at 02:36 PM.

  5. #5
    Registered User
    Join Date
    03-11-2022
    Location
    London, England
    MS-Off Ver
    Professional Plus 2016
    Posts
    15

    Re: Help moving table contents from one sheet to another depending on criteria

    Thank you so much.. that works perfect!!

    Is it possible to use the same process on a bit of a more involved/complicated worksheet such as the one I have attached? I'm sure it must be somehow but with my limited excel knowledge I'm finding it difficult..

    In the attached on the worksheet "Data" we add staff names, start times, finish times and role (from drop-down list) across columns C:D respectively. I would then like to copy each row to the associated location on the "Daily Staffing" sheet dependant on the selection in the 'assigned row' column.

    For example if the entry on row 5 of the "Data" work sheet has "CAT 2" as the assigned role in G5 then I want C5:E5 copied to "Daily Staffing" sheet into the next free row of L14:L27 (Name, Start, Finish) under the Cat 2 heading. This would need to be repeated for each role that we have on the daily staffing sheet.

    Is there a relatively easy way to achieve this or is it too complicated? Thank you again for all your help, it is very much appreciated..
    Attached Files Attached Files

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,227

    Re: Help moving table contents from one sheet to another depending on criteria

    Thread closed. The OP wishes to ask the same question in the Commercial Services section.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Automatically deleting and moving a row to new sheet depending on cell value
    By MissCofnchtr in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-11-2017, 01:54 PM
  2. Moving contents of a cell to another row based on certain criteria?
    By bilge12 in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 06-19-2017, 01:36 PM
  3. Replies: 8
    Last Post: 06-24-2012, 07:38 PM
  4. Moving row to different sheet depending on cell value from drop down list
    By antagius in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-06-2012, 06:06 AM
  5. Moving cell contents to another worksheet table
    By treemkr in forum Excel General
    Replies: 4
    Last Post: 09-09-2010, 12:24 PM
  6. moving to another sheet depending on word
    By iajm@msn.com in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-19-2009, 05:57 PM
  7. macro for moving row contents depending on several conditions
    By gumnut in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-21-2008, 01:37 AM

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