To insert a complete worksheet row immediately below the active cell in Excel for Microsoft 365 on Windows, run a VBA macro that inserts the row numbered ActiveCell.Row + 1. The example below checks that a worksheet is active and that a row exists below the selection before inserting.
VBA code to insert a row below the active cell
Paste this procedure into a standard VBA module. It inserts an entire worksheet row, not just a cell in the active column. The active cell can be anywhere in the row; its column does not change which row is inserted.
Sub InsertRowBelowActiveCell()
Dim ws As Worksheet
Dim insertAt As Long
' Make sure a worksheet, rather than a chart sheet, is active.
If Not TypeOf ActiveSheet Is Worksheet Then
MsgBox "Activate a worksheet first.", vbExclamation
Exit Sub
End If
Set ws = ActiveSheet
insertAt = ActiveCell.Row + 1
' A worksheet cannot have a row below its final row.
If insertAt > ws.Rows.Count Then
MsgBox "There is no worksheet row below the active cell.", vbExclamation
Exit Sub
End If
' Insert the full row and use formatting from the row above.
ws.Rows(insertAt).Insert Shift:=xlDown, _
CopyOrigin:=xlFormatFromLeftOrAbove
End Sub
For example, if the active cell is D8, ActiveCell.Row is 8, so the macro inserts worksheet row 9. Values and formulas that were already in row 9 and below move down. It does not matter whether the active cell contains data: the macro uses its position, not its value.
What the macro changes
The key expression is ActiveCell.Row + 1. The Row property returns the active cell’s worksheet row number, and adding one identifies the row immediately underneath. The Rows(insertAt).Insert statement then inserts that entire row across the worksheet. Existing content below the insertion point shifts down, while content above it remains in place.
This is different from typing into an empty-looking cell or adding a new record at the bottom of a list. The macro changes the worksheet structure at the chosen position. Formulas that refer to affected cells are generally adjusted by Excel as rows are inserted, but review important formulas, named ranges, charts, and external links after structural changes—especially in a complex workbook.
- Active cell: The single cell Excel treats as the current point in the selection.
- Whole worksheet row: The insertion affects every column, including columns that appear empty.
- Direction: Existing cells at and below the insertion point shift down; the macro does not overwrite them.
How to add and run the macro
Save a copy of the workbook before running any macro. VBA actions cannot be undone with Ctrl+Z, so a separate copy gives you a reliable way to restore the original if the macro changes the wrong sheet or row.
- In Excel for Windows, open the workbook and press Alt+F11 to open the Visual Basic Editor. On some keyboards, you may need to press Fn as well.
- In the editor, choose Insert > Module, then paste the procedure into the module window.
- Return to the worksheet and click the cell that determines where the new row will go.
- Press Alt+F8, select
InsertRowBelowActiveCell, and choose Run. You can also run it from the editor with the cursor inside the procedure by pressing F5. - Save the workbook as an Excel Macro-Enabled Workbook (
.xlsm) if you need to retain the VBA code.
If the Developer tab is hidden, enable it on Windows through File > Options > Customize Ribbon, then select Developer under Main Tabs. On a Mac, VBA is available in desktop Excel; use Developer > Visual Basic to open the editor. The keyboard shortcut can vary with the Mac keyboard and function-key settings, so the ribbon command is a dependable route. Excel for the web can open a macro-enabled workbook, but it cannot create, edit, or run VBA macros; open the file in desktop Excel to use this procedure.
Whole row or cells in one column?
“Insert a row below the active cell” can mean two different things. The code above inserts a complete worksheet row, which is usually right when adding a record to a conventional table laid out in rows. If you only want to make space in one column, a whole-row insertion is broader than necessary: it shifts data in every column and may disrupt neighboring lists or layouts.
For a one-column change, select the cell immediately below the active cell and use Excel’s cell-insertion command with a downward shift, or adapt the VBA to insert a single cell rather than an entire row. A one-cell insertion affects only the chosen column’s cell range, leaving adjacent columns where they are. That can be useful in a simple single-column list, but it can misalign related fields—for example, moving a person’s name without moving the matching email address. When columns belong together as records, insert a complete row or add a row through the table’s own controls.
There is another common interpretation: users sometimes want a blank row after the active row in an Excel Table. A table is a structured object with its own rows, headers, formulas, and filter behavior. A worksheet-row insertion may expand or interact with a table depending on where it occurs, but it is not always the clearest way to add a table record. When working inside a table, use its row-insertion option or add a row at the table boundary, then confirm that the table includes the new record and that calculated columns behave as expected.
Formatting and the inserted row
The macro specifies CopyOrigin:=xlFormatFromLeftOrAbove, which tells Excel to use formatting from the row above as the insertion’s formatting origin. This can make a new row match the surrounding data when the rows above and below have different formats. Excel’s Insert operation can also use formatting from below; this setting makes the choice explicit rather than relying on the default behavior.
Formatting is not the same as copying the row’s contents. The procedure inserts a blank row and does not copy the values or formulas from the row above. After insertion, check number formats, borders, fills, conditional formatting, and data validation if the surrounding rows use special rules. A worksheet may also have formatting applied far beyond its visible data, so an inserted row can inherit a style that looks unexpected even when the macro has worked correctly.
If you want the new row to copy formulas or values as well, that is a different operation and should be added deliberately. Blindly copying the whole preceding row can duplicate IDs, dates, or other values that should be unique. For many structured lists, Excel Tables are a better fit because table rows can carry calculated-column formulas and consistent formatting without a macro copying an entire row’s contents.
Common errors and edge cases
A protected worksheet may block row insertion unless the protection settings allow it. If the macro stops with an error, check Review > Protect Sheet and the sheet’s permissions; do not remove protection unless you are authorized to do so. A workbook’s structure protection is separate from worksheet protection and may also affect workbook-level changes, though inserting a row on a sheet is most commonly limited by the sheet itself.
- Active chart sheet: A chart sheet has no worksheet grid. The procedure detects that case and displays a message instead of trying to insert a worksheet row.
- Last worksheet row: Excel worksheets have a fixed row limit. If the active cell is in the final row, there is no row below it, so the macro reports the condition and exits.
- Merged cells: Merged ranges can constrain structural edits and may cause an insertion to fail or produce an awkward layout. Review nearby merges before changing rows in a formatted report.
- Filters and hidden rows: The macro uses the actual worksheet row number, not the next visible row. If a filter hides records, it still inserts immediately below the active cell’s physical row.
- Multiple selected cells: Excel still has one active cell within a multi-cell selection. The macro uses that active cell, which may not be the top-left cell you expected; check the highlighted active cell before running it.
Also check which workbook and worksheet are active. Because the procedure uses ActiveSheet and ActiveCell, running it while a different workbook window is in front inserts a row there instead. A useful safeguard is to click the intended sheet, verify the active cell address in the Name Box, and only then run the macro.
Choosing a macro, shortcut, or table command
A macro is useful when the operation is repeated, needs to be assigned to a button, or forms part of a larger workflow. For a one-time insertion, Excel’s built-in command may be quicker: select the row beneath the intended location, then use Home > Insert > Insert Sheet Rows. This inserts a worksheet row above the selected row, which places it below the row containing the active cell.
On Windows, the row-selection shortcut is Shift+Space; after selecting the row beneath the target, use Ctrl+Shift++ to insert. On Mac, the equivalent row-selection shortcut is generally Shift+Space, while the insert shortcut is Control+Shift+= on many keyboards; keyboard layouts can differ. If the shortcut is inconvenient or behaves differently on your system, use the Home ribbon command instead. These manual methods insert a full worksheet row, just like the macro, and avoid enabling VBA for a task you do only occasionally.
Use a table-specific command when you need to add a record within an Excel Table and preserve its structured behavior. Use a whole worksheet row when the surrounding data spans multiple columns and should move together. Use a cell-only insertion only when shifting one column independently is intentional. The choice is about the scope of the change, not merely which method requires fewer clicks.
Macro safety and workbook compatibility
VBA can make repetitive editing faster, but it can also make changes immediately and without the normal Undo history. Save a backup before running this or any other macro, and inspect the active sheet and cell first. If you receive a security warning, only enable macros in a workbook from a source you trust. Saving as .xlsm preserves VBA; saving as a macro-free .xlsx does not retain the macro code.
The procedure uses standard Excel VBA objects and methods available in desktop Excel for Microsoft 365 on Windows. Excel for Mac supports VBA, although the editor access and keyboard shortcuts can differ. Excel for the web does not execute VBA, so a workbook opened there will not run this macro. For web-based automation, Office Scripts is a separate feature with a different language and execution model; VBA code cannot simply be pasted into an Office Script.
Frequently Asked Questions
Does the macro insert a row below the active cell or below the active row?
It inserts a complete worksheet row below the row containing the active cell. The active cell’s column and value do not change the insertion position.
Will the macro work if I select a range of cells?
Yes, provided a worksheet is active. Excel maintains one active cell within a multi-cell selection, and the macro inserts beneath the row containing that cell. Confirm which cell is active before running it.
Can I insert a row below the last row in Excel?
No. A worksheet has a fixed final row, so there is no row below it. This macro detects that position and displays a message rather than attempting the insertion.
Can I undo a VBA row insertion with Ctrl+Z?
No. Running a VBA macro clears Excel’s ordinary Undo history for that action. Save a copy before running the macro; if the result is wrong, close without saving or restore the backup.
Does this insert a row into an Excel Table?
The procedure asks Excel to insert a worksheet row. If your goal is specifically to add a record to a Table, use the table’s row-insertion controls and confirm the table range, formulas, and formatting afterward.
Can I run the macro in Excel for the web?
No. Excel for the web does not run VBA. Open the macro-enabled workbook in desktop Excel for Windows or Mac to run the procedure.
Related
- Excel Not Responding to Keyboard? Causes and Fixes
- Excel Not Responding? Causes and Fixes
- Excel Not Responding? Recover Files and Find Temp Data
Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.
More in VBA & macros
- How to Copy and Paste VBA Code into ExcelTo copy and paste VBA code into Excel, open the Visual Basic Editor, insert a standard module, paste…
- VBA Loop Types: For, Do, and While ExplainedVBA has four commonly encountered loop constructs: For…Next, For Each…Next, Do…Loop, and While…Wend. Use For…Next when a counter…
- Excel VBA UserForm Tutorial: Build a Data Entry FormTo build an Excel VBA UserForm, open the Visual Basic Editor, insert a UserForm, add controls such as…
- Microsoft Excel Macro Recorder: Record and Run MacrosMicrosoft Excel’s macro recorder captures a sequence of actions in Excel and converts them into VBA code that…
- Excel Macros Disabled: How to Enable Them SafelyTo enable a macro in Excel for Microsoft 365 on Windows, open a workbook you trust and select…
- Excel VBA Delete Row: Methods, Examples, and Best PracticesTo delete a worksheet row with Excel VBA, reference the worksheet and call its Rows collection’s Delete method—for…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.