+ Reply to Thread
Results 1 to 13 of 13

Move row from one table to another on the same sheet based on cell value

  1. #1
    Registered User
    Join Date
    06-08-2017
    Location
    Chesapeake, Virginia
    MS-Off Ver
    2010
    Posts
    18

    Question Move row from one table to another on the same sheet based on cell value

    I have one sheet with 2 tables. Both tables are identical and use columns C:S. I am trying to move the active row from one table to the next empty row on the other and vice versa based on a cell value which can be either "Open" or "Closed" under the table column heading located in Column D called "Status". Currently it is manually typed in. I would like it to move when the value changes on either table. So the top table should only show "Open" items and the bottom table should only show "Closed " items.

    I cant seem to get this to work at all. Here is the code I have, any help is appreciated!

    Please Login or Register  to view this content.

  2. #2
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,198

    Re: Move row from one table to another on the same sheet based on cell value

    Hi GhostRider757

    QUITE STUMPED WITH THIS ONE...HOPE SOMEONE ELSE CAN SIMPLIFY SO I TOO CAN LEARN...
    Put this in Sheet.Module

    Please Login or Register  to view this content.
    Put this in Normal module
    This code will move all the Close to Close table and all open to open table
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by sintek; 07-08-2017 at 11:40 AM. Reason: Not working
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  3. #3
    Registered User
    Join Date
    06-08-2017
    Location
    Chesapeake, Virginia
    MS-Off Ver
    2010
    Posts
    18

    Re: Move row from one table to another on the same sheet based on cell value

    On the workbook you provided it seems to work, but on mine I get "Variable not defined" on TargetRowsCount = .DataBodyRange.Rows.Count

  4. #4
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,198

    Re: Move row from one table to another on the same sheet based on cell value

    Ideally you should upload a sample file so we could test....

    Originally Posted by Pete_UK
    To attach a file, click on Go Advanced (below the Edit Window) while you are composing a reply, then scroll down to and click on Manage Attachments and the Upload window will open. Click on Browse and navigate to (and double-click) the file icon that you want to attach, then click on Upload and then on Close this Window to return to the Edit window. When you have finished composing your post, click on Submit Post.

  5. #5
    Registered User
    Join Date
    06-08-2017
    Location
    Chesapeake, Virginia
    MS-Off Ver
    2010
    Posts
    18

    Re: Move row from one table to another on the same sheet based on cell value

    Quote Originally Posted by sintek View Post
    Ideally you should upload a sample file so we could test....
    I attached a file.
    Attached Files Attached Files

  6. #6
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,198

    Re: Move row from one table to another on the same sheet based on cell value

    See attached....When converting to tables, Table has headings was not included so data was not part of Table data.Body...
    Keep this thread open as I would like top see more solutions....

    edited...A problem i foresee is that some time or other the Open table is going to OVERLAP THE CLOSE TABLE WHICH WILL RENDER ERRORS IN CODE.....
    Attached Files Attached Files
    Last edited by sintek; 07-08-2017 at 02:49 PM.

  7. #7
    Registered User
    Join Date
    06-08-2017
    Location
    Chesapeake, Virginia
    MS-Off Ver
    2010
    Posts
    18

    Re: Move row from one table to another on the same sheet based on cell value

    Quote Originally Posted by sintek View Post
    See attached....When converting to tables, Table has headings was not included so data was not part of Table data.Body...
    Keep this thread open as I would like top see more solutions....

    edited...A problem i foresee is that some time or other the Open table is going to OVERLAP THE CLOSE TABLE WHICH WILL RENDER ERRORS IN CODE.....
    I didnt think of that, good catch!

    Yes, I do see the issue you mention, Under normal circumstances the top table would never fill up enough to run into the bottom table, but when moving rows back and fourth it creates blank rows and deletes the row which makes the available amount of rows for table 2 less and less. Hoping I can find a way to prevent that.

  8. #8
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,198

    Re: Move row from one table to another on the same sheet based on cell value

    Try this code....Ensures that the gap between the Tables remains the same.
    Please Login or Register  to view this content.
    Last edited by sintek; 07-09-2017 at 02:03 PM.

  9. #9
    Registered User
    Join Date
    06-08-2017
    Location
    Chesapeake, Virginia
    MS-Off Ver
    2010
    Posts
    18

    Re: Move row from one table to another on the same sheet based on cell value

    Quote Originally Posted by sintek View Post
    Try this code....Ensures that the gap between the Tables remains the same.
    Please Login or Register  to view this content.
    That did seem to help, however the blank rows that get reproduced when moving from the last row on the top table to the bottom eventually overlap the colored cells above the second table.

  10. #10
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,198

    Re: Move row from one table to another on the same sheet based on cell value

    See upload...perhaps someone else can assist with a more viable solution than this...
    Attached Files Attached Files
    Last edited by sintek; 07-09-2017 at 03:34 PM.

  11. #11
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,198

    Re: Move row from one table to another on the same sheet based on cell value

    Curious to find out what you ended up doing?

  12. #12
    Registered User
    Join Date
    08-29-2022
    Location
    Perth, Australia
    MS-Off Ver
    365
    Posts
    1

    Re: Move row from one table to another on the same sheet based on cell value

    Hey thanks, this works great. Just one thing; after running the macro both tables lose their filter arrows, is there a way to automatically add this back in?
    Thanks again

  13. #13
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Move row from one table to another on the same sheet based on cell value

    Quote Originally Posted by vbaaargh View Post
    Hey thanks, this works great. Just one thing; after running the macro both tables lose their filter arrows, is there a way to automatically add this back in?
    Thanks again
    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #4 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

+ 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. Move Row to another table based on cell value
    By janarthenan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-10-2016, 06:41 PM
  2. [SOLVED] Move Row(s) To Another Sheet (One of Five) Based On One+ Cell Value
    By gothope? in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-22-2016, 07:23 AM
  3. Move or delete cell information based on reference table
    By JW90 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-12-2016, 02:06 AM
  4. [SOLVED] Move Row To a Particular Sheet Based on Cell Value
    By sliesneekr in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-02-2016, 12:16 PM
  5. [SOLVED] Move Rows to another sheet based on Table Title
    By BOFH in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 11-19-2015, 09:53 AM
  6. VBA CODE to move rows from one sheet(1) to another sheet(2) based on data in cell
    By fozzieulo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-08-2013, 02:43 PM
  7. Macro to move rows from one sheet to another sheet based on a cell vaule
    By d55272 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 10-09-2012, 03:33 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