+ Reply to Thread
Results 1 to 29 of 29

Moving rows to another sheet based on a certain field's value.

  1. #1
    Registered User
    Join Date
    09-11-2012
    Location
    Boston, MA
    MS-Off Ver
    Excel 2003
    Posts
    16

    Moving rows to another sheet based on a certain field's value.

    All,

    I'm creating an Action Item List that once column J is changed to "complete", would move the row to a second sheet. I've found on a post that has the solution I need (see hyperlink below) but I don't know how to tweak it so that it uses column J and is extended for a couple of hundred rows.

    Any help would be very much appreciated!!

    Regards,

    ERhttp://www.excelforum.com/excel-prog...lds-value.html

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Moving rows to another sheet based on a certain field's value.

    Would you like to move the row each time the column J is marked as 'complete'? or would you want to update column J for all the required rows and then click on a button to trigger the movement?
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    09-11-2012
    Location
    Boston, MA
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: Moving rows to another sheet based on a certain field's value.

    Hi Arlette,

    I would like to have the row moved when marked complete, but either solution would work.

    Eric

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Moving rows to another sheet based on a certain field's value.

    The code would differ in each case (button v/s instant) so if you let me know which type, i can assist you.

  5. #5
    Registered User
    Join Date
    09-11-2012
    Location
    Boston, MA
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: Moving rows to another sheet based on a certain field's value.

    Instant would be great. Thank you so much for the quick response!!

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Moving rows to another sheet based on a certain field's value.

    What is the data range you have? From column A to?

  7. #7
    Registered User
    Join Date
    09-11-2012
    Location
    Boston, MA
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: Moving rows to another sheet based on a certain field's value.

    A to J. Here is a snap shot of the headers, if that helps.

    Capture.JPG

  8. #8
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Moving rows to another sheet based on a certain field's value.

    So your headers are in row 6?

  9. #9
    Registered User
    Join Date
    09-11-2012
    Location
    Boston, MA
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: Moving rows to another sheet based on a certain field's value.

    That is correct.

  10. #10
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Moving rows to another sheet based on a certain field's value.

    I modified the code in your linked post as below -
    Please Login or Register  to view this content.
    Right click on the sheet where you have the data and select "View Code". Copy paste the above code there.
    Let me know if you face any issues.

  11. #11
    Registered User
    Join Date
    09-11-2012
    Location
    Boston, MA
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: Moving rows to another sheet based on a certain field's value.

    I get the following error message:

    Run-time error '9':

    Subscript out of range

    User error, perhaps??

  12. #12
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Moving rows to another sheet based on a certain field's value.

    Is your "Complete" sheet spelt in the same way, with respect to case and spelling?

  13. #13
    Registered User
    Join Date
    09-11-2012
    Location
    Boston, MA
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: Moving rows to another sheet based on a certain field's value.

    Yes, it is spelled the same, with the same upper case C. I choose it from a data validation drop down list that has two options: In Progress / Complete, if that matters.

  14. #14
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Moving rows to another sheet based on a certain field's value.

    I am asking you about your sheet name. Is it spelt correctly - as "Complete" ?

  15. #15
    Registered User
    Join Date
    09-11-2012
    Location
    Boston, MA
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: Moving rows to another sheet based on a certain field's value.

    Sorry. Not, the sheet is titled Action Items and the second sheet is titled Completed Action Items.

  16. #16
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Moving rows to another sheet based on a certain field's value.

    Updated code here -
    Please Login or Register  to view this content.

  17. #17
    Registered User
    Join Date
    09-11-2012
    Location
    Boston, MA
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: Moving rows to another sheet based on a certain field's value.

    Still getting an error message. This time:

    Run-time error '13':

    Type mismatch

    Sorry for the hassle!!

  18. #18
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Moving rows to another sheet based on a certain field's value.

    Is this line highlighted?
    Please Login or Register  to view this content.
    Change it to
    Please Login or Register  to view this content.

  19. #19
    Registered User
    Join Date
    09-11-2012
    Location
    Boston, MA
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: Moving rows to another sheet based on a certain field's value.

    That works wonderfully. Just one issue: it only works on rows that are on the sheet, but not new rows: example - if I add something to row 12 and change J12 to "Complete" it does not move it. Records that are already on the sheet work fine and are moved to the "Completed Action Items" sheet.

  20. #20
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Moving rows to another sheet based on a certain field's value.

    Do you have a sample excel file that you can upload?

  21. #21
    Registered User
    Join Date
    09-11-2012
    Location
    Boston, MA
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: Moving rows to another sheet based on a certain field's value.

    Yes, please see the attached sample. Let me know if additional information would be of help!
    Attached Files Attached Files

  22. #22
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Moving rows to another sheet based on a certain field's value.

    I tested it and it works.

  23. #23
    Registered User
    Join Date
    09-11-2012
    Location
    Boston, MA
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: Moving rows to another sheet based on a certain field's value.

    Hmm, maybe I'm doing something wrong. The sheet I uploaded has row J8 and row J14 as "Complete", yet it did not move the row. The sheet is enabled...what am I missing?

  24. #24
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Moving rows to another sheet based on a certain field's value.

    It depends on how the data was entered into those 2 rows. I did a test on your whole file uptil row 20 and it worked fine.

    Clear out your data and put it afresh into the tab and check.

  25. #25
    Registered User
    Join Date
    09-11-2012
    Location
    Boston, MA
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: Moving rows to another sheet based on a certain field's value.

    It works if you clear the rows in sequence, but if you change one of the rows that is not the top row, it will not work.

  26. #26
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Moving rows to another sheet based on a certain field's value.

    I got it.
    Updated code here -
    Please Login or Register  to view this content.
    You had used the same variable LR to check for the lastrow in the source sheet and the destination sheet, hence it was not working for some rows.

  27. #27
    Registered User
    Join Date
    09-11-2012
    Location
    Boston, MA
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: Moving rows to another sheet based on a certain field's value.

    Unfortunately, it is not working for me....and now the first row after the header is overwriting the line so the "Completed Items" sheet only has 1 row total.

  28. #28
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Moving rows to another sheet based on a certain field's value.

    Which is the column in the main sheet which will always have an entry?

    Edit:

    Try this
    Please Login or Register  to view this content.

  29. #29
    Registered User
    Join Date
    09-11-2012
    Location
    Boston, MA
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: Moving rows to another sheet based on a certain field's value.

    WE HAVE A WINNER!!! How do I give you a 1000 stars! I'll update to Solved. Thanks a million!!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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