Copy Excel VBA Rows Below a Destination Sheet Header
Question details
Copy matching rows to a destination worksheet starting at a fixed row below a reserved area.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A VBA macro needs to refresh matching records on a destination sheet without overwriting titles, analysis, or column headers above the output.
- Observed behavior
- Matching records should start at the chosen output row, with the reserved area above it left unchanged.
Identify the first output row, the source and destination sheet names, and the columns that the macro may overwrite. Save the workbook as an Excel Macro-Enabled Workbook (.xlsm) if it is not already in a macro-enabled format.
Set a Fixed Starting Row and Clear Only the Output Range
Use this approach when rows above the output are reserved for titles, analysis, and headers.
The example assumes source data is in columns A:E, column A contains the matching value, and destination headers are on row 10. It clears A11:E10000 before copying; change the sheet names, match value, and ranges to fit your workbook.
In Excel, open Developer > Visual Basic, then select Insert > Module.
Paste the following code into the module: Sub CopyMatchingRows() Dim sourceSheet As Worksheet, destinationSheet As Worksheet Dim lastRow As Long, sourceRow As Long, destinationRow As Long Set sourceSheet = ThisWorkbook.Worksheets("Source") Set destinationSheet = ThisWorkbook.Worksheets("Destination") lastRow = sourceSheet.Cells(sourceSheet.Rows.Count, "A").End(xlUp).Row destinationRow = 11 destinationSheet.Range("A11:E10000").ClearContents For sourceRow = 2 To lastRow If sourceSheet.Cells(sourceRow, "A").Value = "Approved" Then If destinationRow > 10000 Then MsgBox "The destination output range is full." Exit Sub End If sourceSheet.Range("A" & sourceRow & ":E" & sourceRow).Copy _ Destination:=destinationSheet.Range("A" & destinationRow) destinationRow = destinationRow + 1 End If Next sourceRow End Sub
In the code, replace Source, Destination, and Approved with your sheet names and matching value. If you change the first output row or last output row, update destinationRow, the cleared range, and the capacity check together.
Return to Excel, select Developer > Macros, choose CopyMatchingRows, and click Run. Check that matching rows begin at row 11 and that the reserved rows above remain unchanged.

Work With Excel Spreadsheets in WPS Office
WPS Office is a free, lightweight alternative with a familiar spreadsheet interface and support for Excel formats, making it easy to move everyday spreadsheet work. VBA support can vary by edition and setup, so verify macro compatibility before relying on this Excel macro.

Frequently Asked Questions
How do I start copying at a different row?
Change destinationRow = 11 to your first output row. Also change the start of the ClearContents range so it begins at the same row and does not include your headers.
Will ClearContents remove my destination headers?
Not if the cleared range starts below them. For example, Range("A11:E10000").ClearContents leaves headers in row 10 untouched, but removes values and formulas within the specified range.
How do I change which rows are copied?
Edit the If condition in the VBA editor. For example, replace "Approved" with the value you want to match in source column A, or change the column reference to match another column.
Why does the macro stop when the destination range is full?
The example limits output to row 10000 to avoid writing outside the cleared area. If you need more space, enlarge the ClearContents range and update the destinationRow capacity check to the same last row.




