You can move rows from one worksheet to another with a short VBA macro that copies the entire row and then deletes it from the source. This is useful for splitting a master list into separate sheets by status, region, or any other criterion. The approach below uses AutoFilter to select matching rows, copies them to the destination sheet in one block, and then deletes them from the source. You will need the Developer tab enabled in Excel and a workbook saved as .xlsm (macro-enabled) before you start.

What You'll Need

  • Excel with the Developer tab visible (File > Options > Customize Ribbon > check Developer).
  • A workbook saved as .xlsm, because standard .xlsx files cannot store macros.
  • A source sheet with a header row and consistent data, plus a destination sheet (create one if it does not exist).
  • Basic familiarity with the VBA editor (Alt+F11 opens it).

Step-by-Step

  1. Open the VBA editor. Press Alt+F11. In the Project Explorer, right-click your workbook and choose Insert > Module. A blank code window appears.
  2. Name your sheets in the code. Decide the exact tab names of the source and destination sheets. The code below uses "Master" and "Archive"; change these to match your workbook. Sheet names are case-sensitive in the string but not in the tab, so copy them exactly.
  3. Paste the macro. Use this skeleton and adjust the filter column and criteria:
    Sub MoveRows()
        Dim src As Worksheet, dst As Worksheet
        Dim lastRow As Long, lastDest As Long
        Set src = ThisWorkbook.Worksheets("Master")
        Set dst = ThisWorkbook.Worksheets("Archive")
        lastRow = src.Cells(src.Rows.Count, "A").End(xlUp).Row
        If lastRow < 2 Then Exit Sub
        src.Range("A1:Z" & lastRow).AutoFilter Field:=3, Criteria1:="Closed"
        lastDest = dst.Cells(dst.Rows.Count, "A").End(xlUp).Row + 1
        src.Range("A2:Z" & lastRow).SpecialCells(xlCellTypeVisible).Copy Destination:=dst.Range("A" & lastDest)
        src.Range("A2:Z" & lastRow).SpecialCells(xlCellTypeVisible).Delete
        src.AutoFilterMode = False
    End Sub
  4. Set the filter field and criteria. The Field:=3 argument refers to the third column in the filtered range (column C if your range starts at A). Change the number to the column that holds your criterion, and change "Closed" to your value. For text that contains a word rather than matching exactly, use Criteria1:="*word*".
  5. Adjust the column range. The example uses A:Z. If your data has more columns, extend the range (for example A:AZ). If it has fewer, narrow it so you do not copy empty columns.
  6. Check the destination header. The macro assumes the destination sheet already has a header row in row 1. If it does not, add one before running the macro, or the first copied row will land in row 1 and overwrite nothing but will sit above your data.
  7. Run the macro. Close the VBA editor, press Alt+F8, select MoveRows, and click Run. The matching rows are copied to the destination and then deleted from the source.
  8. Save and test on a copy. Before running on live data, save a duplicate of the workbook and run the macro there. Confirm the rows land in the right place and that the source sheet still has the rows you expected to keep.

Common Mistakes

  • Forgetting to turn off AutoFilter. If you do not reset AutoFilterMode = False, the source sheet stays filtered and later runs may behave unpredictably.
  • Using the wrong Field number. Field counts from the left edge of the filtered range, not from column A of the sheet. If your range starts at B, Field 1 is column B.
  • Deleting before copying. Always copy first, then delete. Reversing the order loses the data.
  • Destination header missing. Without a header row, the first pasted row becomes the header and your data shifts.
  • Running on a protected sheet. If either sheet is protected, the macro fails. Unprotect both sheets first (Review > Unprotect Sheet).
  • Using .xlsx. Macros are stripped from .xlsx files on save. Save as .xlsm.

Tips

  • Add Application.ScreenUpdating = False at the start and True at the end to speed up large moves.
  • Use a named range or a variable for the last row so the macro adapts when data grows.
  • If you want to copy without deleting, remove the .Delete line.
  • Test with a small subset first; a macro that deletes rows cannot be undone with Ctrl+Z.
  • Keep a backup copy of the workbook before running any macro that deletes data.

Troubleshooting

If the macro does nothing, check that the sheet names in the code match the tab names exactly. If you get a "Subscript out of range" error, one of the worksheet names is wrong or the sheet does not exist. If rows are copied but not deleted, confirm the delete line runs after the copy and that the sheet is not protected. If the destination receives blank rows, your range includes empty columns; narrow the range. If the macro is slow on thousands of rows, turn off screen updating and calculation temporarily. If you see a "Method 'Range' of object '_Worksheet' failed" error, the last row calculation returned 0 or the range is invalid; check that column A has data in every row you expect to move.

Frequently Asked Questions

Can I move rows based on a cell value in one column?

Yes. Set the AutoFilter Field to that column's position within the range and set Criteria1 to the value you want, such as "Open" or a number.

Will this work in Excel for Mac?

The VBA code is the same, but the Developer tab location and some shortcut keys differ. Use the Tools > Macro menu if Alt+F8 does not respond.

Can I move rows to a new sheet automatically?

You can add code to create the destination sheet if it does not exist, but the simpler approach is to create it manually first and reference it by name.

What happens to formulas in the moved rows?

Formulas are copied as-is. Relative references may point to different cells on the destination sheet, so check them after the move.

Can I undo a macro that moved rows?

No. VBA actions are not added to the undo stack. Always run on a copy or keep a backup.