+ Reply to Thread
Results 1 to 4 of 4

Macro to move rows of text to another sheet

  1. #1
    Forum Contributor
    Join Date
    12-09-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    201

    Macro to move rows of text to another sheet

    I have a spreadsheet which contains two sheets, both of which are virtually identical. In Sheet 1, Column O is always blank, "No", or "Yes" for each row, and columns A to N have various data entered for each row. I have a button on Sheet 1 which runs this macro:

    Please Login or Register  to view this content.
    The idea is that there will be various rows of data on Sheet 1, all with "Yes" or "No" in column O. This macro is supposed to look at every row in Sheet 1 one at a time (beginning with row 3 and ending with the last row where there is a value in column O), and check to see what the cell value is in column O. If it is "Yes", then it is supposed to:

    1 - Cut the data in columns A-N in Sheet 1
    2 - Go to Sheet 2, and paste the cut data into row 3 (shifting the other cells down)
    3 - Go back to Sheet 1, and delete the data for that row in columns A-N, shifting the cells below up by one
    4 - See if there is anything in column O again (as it is now the next row of data)
    5 - If there is a "Yes", then go back to step 1

    The problem is, sometimes it doesn't do anything, and when it does work, it moves only one record to Sheet 2, and to row 4 not row 3. And it messes up the formula reference in column O, because it deletes cells and shifts them up.

    Any help appreciated.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Macro to move rows of text to another sheet

    Please Login or Register  to view this content.
    If solved remember to mark Thread as solved

  3. #3
    Forum Contributor
    Join Date
    12-09-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    201

    Re: Macro to move rows of text to another sheet

    That almost works. The pasted text is Sheet 2 was getting pasted into row 2 though, overwriting the column headers, so I updated drow to equal 3 instead of 2. The thing is, it seems like this macro overwrites the same rows in Sheet 2 each time, and I need any existing rows of text to be moved down first. I've updated the macro to this:

    Please Login or Register  to view this content.
    Last edited by ianpwilliams; 06-12-2013 at 12:56 PM.

  4. #4
    Forum Contributor
    Join Date
    12-09-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    201

    Re: Macro to move rows of text to another sheet

    Never mind I think I have it working:

    Please Login or Register  to view this content.
    Thanks for the help! Solved!
    Last edited by ianpwilliams; 06-12-2013 at 01:17 PM.

+ 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