+ Reply to Thread
Results 1 to 4 of 4

Move row if matches criteria

  1. #1
    Registered User
    Join Date
    09-11-2009
    Location
    MN
    MS-Off Ver
    Office 2010
    Posts
    48

    Move row if matches criteria

    I am using the following code in "Worksheet Change" to see if a column contains the word "Deleted" - if it does, it cuts the row and pastes it on the first blank row on a different worksheet, then it removes the row from the original sheet so that I dont have any gaps in my data. The code works great except if the word is on the very last row, then it only moves the row up to the column and leaves behind all the data that falls after it.

    How many rows and columns are not static, the only thing that is certain is that the word "Deleted" will be in this column all the time.

    Any idea how I can fix this? Thank you!

    Please Login or Register  to view this content.
    Last edited by XLVBA; 05-31-2010 at 04:07 PM.

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Move row if matches criteria

    The code works great except if the word is on the very last row, then it only moves the row up to the column and leaves behind all the data that falls after it.
    Can you explain what you mean by this? If the word is on the very last row, how can there be "data that falls after it"?
    And how is the row moved up the column?

    I ran your macro and it seems to work OK. But then, I don't have your data.

  3. #3
    Registered User
    Join Date
    09-11-2009
    Location
    MN
    MS-Off Ver
    Office 2010
    Posts
    48

    Re: Move row if matches criteria

    Oops. I'm sorry, I mispoke. My apologies.

    It is moved to the new sheet, but...

    Lets say there are 12 rows, and on row 12, the word "Deleted" is in the 5th column. It will copy and move that all to a new sheet, but from column 6 through 10 (for example) of row 12 it is still left on the original sheet, instead of being deleted with the:

    Please Login or Register  to view this content.
    which is what I'm using to move the row up. If it falls on rows 1-11 it is deleted just fine.

    Does that make sense?

  4. #4
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Move row if matches criteria

    works fine for me in xl 2010.

    Rows are moved and cleared completely. No leftover data, regardless of last row or not.

    Have you tried stepping through your code, maybe with a few Select statements thrown in to see what's happening?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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