+ Reply to Thread
Results 1 to 22 of 22

Move row to another sheet based on cell value

  1. #1
    Registered User
    Join Date
    11-13-2018
    Location
    Canada
    MS-Off Ver
    Office 2016
    Posts
    12

    Move row to another sheet based on cell value

    Hi Everyone,

    I've seen multiple threads on that topic, and I've tried tweaking my code but there is something I am still unable to do.
    I would like to move a row in Sheet1 to Sheet2 if the value in column J is "Changes Required".

    My code below seems to be working when "Sheet2" is empty, but when I have a header in Sheet2 with content up to row 5, the deleted row from Sheet1 does not come over Sheet2. It just disappears. My guess is that it's trying to paste in row 1 and since there's content in it, it does not work.

    Also, I'd like my code to run automatically rather than having to manually click on Run.


    Please Login or Register  to view this content.
    Thanks!
    M5B

  2. #2
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Move row to another sheet based on cell value

    Try:
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    11-13-2018
    Location
    Canada
    MS-Off Ver
    Office 2016
    Posts
    12

    Re: Move row to another sheet based on cell value

    Hi porucha vevrku

    I tried your code and nothing happens.

    Below is a screenshot of Sheet1. If I type "Changes Required" in J5, I'd like the line to be deleted and moved to Sheet2.
    Sheet2 is a duplicated of Sheet1 but it's only for "Revisions Required" rows.

    Thanks!
    M5B
    Attached Images Attached Images
    Last edited by M5B; 12-10-2018 at 10:16 PM.

  4. #4
    Valued Forum Contributor mohan.r1980's Avatar
    Join Date
    09-18-2010
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010 (windows7)
    Posts
    729

    Re: Move row to another sheet based on cell value

    Hi M5B,

    not sure but just try in Your code

    Please Login or Register  to view this content.
    Regards,
    MohanS


    "Perfection is not attainable, but if we chase perfection we can catch excellence." - Vince Lombardi

    You can simply say thanks by clicking "*Add Reputation" icon

  5. #5
    Registered User
    Join Date
    11-13-2018
    Location
    Canada
    MS-Off Ver
    Office 2016
    Posts
    12

    Re: Move row to another sheet based on cell value

    Hi Mohan,

    I tried with this line and it does not work. The row does not come over to Sheet2.

    This seems like a tough one!

    Thanks,
    M5B

  6. #6
    Valued Forum Contributor mohan.r1980's Avatar
    Join Date
    09-18-2010
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010 (windows7)
    Posts
    729

    Re: Move row to another sheet based on cell value

    hi
    may be try to change

    Please Login or Register  to view this content.
    to

    Please Login or Register  to view this content.

  7. #7
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Move row to another sheet based on cell value

    Quote Originally Posted by M5B View Post
    ... and nothing happens ...
    You have a different table range with data, can you specify it ?
    The rows and columns of the macro must be adapted to the scope of the data.

  8. #8
    Registered User
    Join Date
    11-13-2018
    Location
    Canada
    MS-Off Ver
    Office 2016
    Posts
    12

    Re: Move row to another sheet based on cell value

    Hi Mohan,
    This does not work, it does not even delete the rows in Sheet1.

  9. #9
    Registered User
    Join Date
    11-13-2018
    Location
    Canada
    MS-Off Ver
    Office 2016
    Posts
    12

    Re: Move row to another sheet based on cell value

    Quote Originally Posted by porucha vevrku View Post
    You have a different table range with data, can you specify it ?
    The rows and columns of the macro must be adapted to the scope of the data.
    I am not sure I understand what you are asking?

    As mentioned in my previous screenshot, Sheet1 and Sheet2 are duplicate in terms of structure. There is copy up to A4 and the data I want to move starts at A5.

  10. #10
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Move row to another sheet based on cell value

    How many columns does the table have ?
    Is there a minimum one-column gap between the data in the last column of the table and the rest of the data in the worksheet ?

  11. #11
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,523

    Re: Move row to another sheet based on cell value

    Are you sure there's entries in Col. J of Sheet1 that say "Changes Required"? In your original post the code is only looking for text that says "Revisions Required" so do you need both transferred?
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  12. #12
    Valued Forum Contributor mohan.r1980's Avatar
    Join Date
    09-18-2010
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010 (windows7)
    Posts
    729

    Re: Move row to another sheet based on cell value

    Quote Originally Posted by M5B View Post
    Hi Mohan,
    This does not work, it does not even delete the rows in Sheet1.
    i have amend your code but not sure about output because you haven't provided dummy sample file.
    just try

    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    11-13-2018
    Location
    Canada
    MS-Off Ver
    Office 2016
    Posts
    12

    Re: Move row to another sheet based on cell value

    Quote Originally Posted by Trebor76 View Post
    Are you sure there's entries in Col. J of Sheet1 that say "Changes Required"? In your original post the code is only looking for text that says "Revisions Required" so do you need both transferred?
    There's a "TBD" in my example. And when I type "Revisions Required" and run the macro, it deletes the row but does not move it to Sheet2

  14. #14
    Registered User
    Join Date
    11-13-2018
    Location
    Canada
    MS-Off Ver
    Office 2016
    Posts
    12

    Re: Move row to another sheet based on cell value

    I am not sure how to upload an Excel file so I've included 2 new screenshots. 1 is Sheet1 and 1 is Sheet2
    There are empty cells on Sheet1 - would that be the issue?
    Attachment 601782
    Attachment 601783

  15. #15
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,523

    Re: Move row to another sheet based on cell value

    Try this (though initially on a copy of your data as the results cannot be undone if they're not as expected):

    Please Login or Register  to view this content.
    Note this worked on sample data for me.

    Regards,

    Robert

  16. #16
    Registered User
    Join Date
    11-13-2018
    Location
    Canada
    MS-Off Ver
    Office 2016
    Posts
    12

    Re: Move row to another sheet based on cell value

    Quote Originally Posted by Trebor76 View Post
    Try this (though initially on a copy of your data as the results cannot be undone if they're not as expected):

    Note this worked on sample data for me.

    Regards,

    Robert
    Hi Robert,

    I'll do some proper testing on my file tomorrow, but so far it seems to be working.
    Your VBA code looks very complex though, I'm having a hard time understanding (I like to understand how things work and how each line actions something)

    Thank you so much to everybody that helped!

  17. #17
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,523

    Re: Move row to another sheet based on cell value

    I'm glad we finally got it sorted. Please remember to mark the thread as solved once you've completed your testing.

  18. #18
    Registered User
    Join Date
    11-13-2018
    Location
    Canada
    MS-Off Ver
    Office 2016
    Posts
    12

    Re: Move row to another sheet based on cell value

    Hi Robert,

    So I've been working around the code trying to add a second criteria and I could not make it work.

    I'd like to add a second criteria for the same column, J, so that if I type "Ready for delivery" it sends the line to Sheet3. If possible, I'd like it to be auctioned through the same macro (I run it once and it moves the lines to Sheet2 or Sheet3 based on the value in column J)

    Thanks
    M5B

  19. #19
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,523

    Re: Move row to another sheet based on cell value

    Hi M5B,

    Try this:

    Please Login or Register  to view this content.
    Regards,

    Robert

  20. #20
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,523

    Re: Move row to another sheet based on cell value

    Slightly more succinct way:

    Please Login or Register  to view this content.
    Robert

  21. #21
    Registered User
    Join Date
    11-13-2018
    Location
    Canada
    MS-Off Ver
    Office 2016
    Posts
    12

    Re: Move row to another sheet based on cell value

    Works perfectly, thanks so much Robert!

  22. #22
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,523

    Re: Move row to another sheet based on cell value

    You're welcome. If you could please mark the thread as solved (click on the link in my signature if you're not sure how) it would be appreciated.

    Thanks,

    Robert

+ 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 from one table to another on the same sheet based on cell value
    By Ghostrider757 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 08-30-2022, 12:48 AM
  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. [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
  4. [SOLVED] Move a hyperlink to a new sheet based on a cell value
    By rosshkerr in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-20-2015, 04:21 PM
  5. 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
  6. Move row of data from one sheet to another based on cell value
    By Kaz09 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-09-2012, 09:48 AM
  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