VBA & Macro Problems

Excel VBA: Append Macro Output Below Existing Data

Ayan MasoodAyan Masood Nov 12, 2026 868 views

Question details

The user needs a second VBA procedure to add its results below existing data without overwriting the first procedure's output.

Product
Microsoft Excel VBA
Device & OS
not provided
Scenario
Multiple VBA procedures write results to the same output sheet named Op.
Observed behavior
The second procedure resets the output row and overwrites data created by the first procedure.
Before you start

Check the destination sheet name and identify the column that is always populated for each output row. Review the second procedure for any code that resets the row number or clears the destination range before writing.

Solution 1Recommended

Find the next available row before writing VBA output

Use this fix when a second procedure must append records to the existing data on the Op sheet.

The output row must be calculated from the current contents of the destination sheet rather than reset to a fixed row such as 2. The last-used-row method is generally reliable when column A contains a value for every output record.

1
Open the second procedure

In Excel, press Alt+F11 to open the Visual Basic Editor, then open the module containing the second VBA procedure.

2
Calculate the next empty row

Replace the fixed row assignment with: rw = Sheets("Op").Cells(Sheets("Op").Rows.Count, 1).End(xlUp).Row + 1

3
Write output from that row

Keep the existing write statements, such as Cells(rw, column).Value, so the procedure starts below the last populated cell in column A.

4
Run both procedures

Return to Excel, use Developer > Macros, and run the procedures in sequence to confirm that the second result appears below the first.

Alternative row calculation: If the destination data is a continuous region, you can use rw = Sheets("Op").Cells(1, 1).CurrentRegion.Rows.Count + 1 instead.
Free Microsoft Office alternative

Switch to WPS Office for lightweight spreadsheet work

WPS Office provides a free, lightweight spreadsheet alternative with a familiar interface and strong Microsoft Excel format compatibility. It can help you review, edit, and migrate spreadsheet data when you do not need Excel-specific VBA behavior.

Open and edit common Microsoft Excel .xls and .xlsx files with a familiar spreadsheet interface.Support common .xlsm workbook workflows where compatible, while Excel remains the best choice for complex VBA projects.Use a lightweight alternative for reviewing output tables and checking whether data is appended below existing rows.Move between WPS Spreadsheets and Microsoft Excel with broadly compatible workbook formatting.
QA img-9

Frequently Asked Questions

Why does the second Excel VBA procedure overwrite the first result?

The procedure is usually resetting the output row to a fixed value such as 2, or clearing the destination range before writing. Calculate the next available row on the Op sheet instead.

What VBA code appends output after the last used row?

Use rw = Sheets("Op").Cells(Sheets("Op").Rows.Count, 1).End(xlUp).Row + 1, then write the new values using rw as the row number.

Can I use CurrentRegion to find the next output row?

Yes. For a continuous data region beginning at A1, use rw = Sheets("Op").Cells(1, 1).CurrentRegion.Rows.Count + 1. This method may be unreliable if the region contains blank rows.

Which column should be used with End(xlUp)?

Use a column that is populated for every output record, commonly column A. If column A can be blank, select another consistently filled column or calculate the last used row from the complete output range.

Should the second procedure clear CurrentRegion before appending?

No. Clearing CurrentRegion removes the existing output that you want to preserve. Calculate the next empty row and write the new data below the current region instead.