To append data in Excel VBA, use the Cells or End(xlUp) method to find the next empty row and write your new values there. The simplest working pattern is Dim r As Long: r = Cells(Rows.Count, 1).End(xlUp).Row + 1: Cells(r, 1).Value = "New data". This finds the last used row in column A and writes to the row below it, so existing records stay untouched. The steps below cover that pattern, how to append a whole row or a range, and the mistakes that cause overwritten data.

What You'll Need

  • Excel with the Developer tab enabled (File > Options > Customize Ribbon > check Developer). Menu labels can differ slightly by version and region.
  • A workbook saved as .xlsm (macro-enabled) if you want to keep the code.
  • A target sheet with a header row and at least one data column, so the last-row logic has something to find.
  • Basic familiarity with the VBA editor (Alt+F11).

Step-by-Step

  1. Open the VBA editor. Press Alt+F11. In the Project pane, right-click your workbook and choose Insert > Module. A blank module opens.
  2. Write the basic append macro. Paste this and change the sheet name and column to match your data:
    Sub AppendRow()
        Dim ws As Worksheet
        Dim nextRow As Long
        Set ws = ThisWorkbook.Sheets("Data")
        nextRow = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row + 1
        ws.Cells(nextRow, 1).Value = "New record"
        ws.Cells(nextRow, 2).Value = Date
    End Sub
    This writes to the first empty row in column A and puts today's date in column B.
  3. Run it. Press F5 or use Run > Run Sub. Switch back to Excel and confirm the new row appears below your existing data, not on top of it.
  4. Append a whole row from variables. Replace the hard-coded values with variables so the macro can be reused:
    Dim newName As String, newAmount As Double
    newName = InputBox("Name?")
    newAmount = Val(InputBox("Amount?"))
    ws.Cells(nextRow, 1).Value = newName
    ws.Cells(nextRow, 2).Value = newAmount
  5. Append a range in one line. If you already have values in another range, copy them to the next row with ws.Cells(nextRow, 1).Resize(1, 5).Value = Array("A", "B", "C", "D", "E"). Adjust the column count to match your table.
  6. Append from another sheet. Point the source and destination separately: read the last row of the source with End(xlUp), then write to the destination's next row. Never assume both sheets have the same last row.
  7. Add a guard against blank columns. If column A can be empty but other columns are filled, base the last-row check on a column that is always populated, such as an ID column, or use ws.UsedRange.Rows.Count as a fallback.
  8. Save and test with a copy. Save the workbook as .xlsm, then run the macro on a duplicate file first. Check that headers, formulas, and formatting in existing rows are unchanged.

Common Mistakes

  • Using ActiveCell or a fixed row number. This overwrites data whenever the active cell is not at the bottom. Always calculate the next row.
  • Checking the wrong column with End(xlUp). If column A has blanks, the macro writes into the middle of your table. Pick a column that is never blank.
  • Forgetting + 1. Without it, the macro overwrites the last existing row.
  • Appending to a table without resizing it. If your data is an Excel Table (ListObject), writing below it leaves the new row outside the table. Use ListObjects("Table1").ListRows.Add instead.
  • Not qualifying the worksheet. Omitting ws. makes VBA act on whatever sheet is active, which may be the wrong one.
  • Leaving ScreenUpdating on in loops. Appending many rows one at a time is slow; turn off screen updating and calculation during bulk appends, then turn them back on.

Tips

  • Store the next row in a Long variable, not an Integer, because modern sheets exceed the Integer limit.
  • For many rows, build the data in an array and write it in one assignment to the target range; this is far faster than cell-by-cell writes.
  • Use Application.WorksheetFunction.CountA only when blanks are not expected; otherwise End(xlUp) is more reliable.
  • Add a timestamp column so you can audit when each row was appended.
  • Keep the append macro in its own module and call it from buttons or other procedures rather than duplicating the code.

Troubleshooting

The macro overwrote the last row. You are missing the + 1, or the last-row check is looking at a column that ends earlier than your data. Recheck which column you pass to Cells(Rows.Count, n).

Data lands in the wrong sheet. Qualify every reference with the worksheet variable, and avoid ActiveSheet unless you truly mean the visible sheet.

Run-time error 1004. This usually means the sheet name in Sheets("Data") does not match, or the workbook is protected. Check the tab name exactly, including spaces, and unprotect the sheet if needed.

The new row is outside the table. Convert the append to use ListRows.Add so the table expands and formulas carry down.

Nothing happens when you run it. Macros may be disabled. Check the Trust Center macro settings and confirm the file is saved as .xlsm, not .xlsx.

It is very slow. Wrap bulk appends with Application.ScreenUpdating = False and Application.Calculation = xlCalculationManual, then restore both at the end.

Frequently Asked Questions

How do I append data to the next empty row in Excel VBA?

Use Cells(Rows.Count, 1).End(xlUp).Row + 1 to get the next row, then write to Cells(nextRow, column). This works on any sheet as long as you qualify the reference with the worksheet object.

Can I append a whole row at once instead of cell by cell?

Yes. Assign an array to a resized range, for example ws.Cells(nextRow, 1).Resize(1, 3).Value = Array(a, b, c). This is faster and keeps the code shorter.

Why does my macro overwrite existing data?

The most common cause is a missing + 1 after the last-row calculation, or checking a column that has blank cells partway down. Use a column that is always populated.

How do I append to an Excel Table with VBA?

Use the table object: ActiveSheet.ListObjects("Table1").ListRows.Add adds a row inside the table, so formats and formulas extend automatically.

Can I append data from one workbook to another?

Yes. Open both workbooks, read the last row in the source, then calculate the next row in the destination and copy the values across. Always qualify both workbook and worksheet references.

Does appending data with VBA work on Excel for Mac?

The core methods (Cells, End(xlUp), ListRows.Add) work on Mac Excel, but some Windows-only features and file paths differ. Test the macro on the target platform before relying on it.