How to return the index of rows of a table in Excel as an array on separate cells?

Abstract: Generate a dynamic vertical list of row indices for an Excel table that automatically updates when rows are added or deleted.

Created: 2026-09-07 by
To return the index of rows in an Excel table as a dynamic array, use the SEQUENCE function combined with ROWS. Enter =SEQUENCE(ROWS(Table1)) in the first cell of your target range. This formula generates a vertical list of numbers from 1 to the total number of rows in the specified table, automatically spilling into adjacent cells if you are using Excel 365 or Excel 2021.

Understanding Dynamic Arrays in Modern Excel

The ability to return an array of values from a single cell is a hallmark of modern Excel versions (Microsoft 365 and Excel 2021+). Previously, users had to press Ctrl+Shift+Enter to create legacy array formulas. Today, functions like SEQUENCE, RANDARRAY, and SORT are "dynamic arrays" that spill results into neighboring cells automatically. When working with structured references like Table1, this behavior allows for highly responsive dashboards where row indices update instantly when rows are added or deleted.

The SEQUENCE Function Explained

The core tool for this task is the SEQUENCE function. Its syntax is straightforward: SEQUENCE([rows], [columns], [start], [step]). For generating row indices, we primarily rely on the first two arguments.

  • rows: The number of rows in the generated array. By using ROWS(Table1), we ensure this number changes dynamically as the table grows or shrinks.
  • columns: The number of columns in the generated array. Since we want a vertical list of row numbers, we leave this at its default value of 1.
  • start: The starting number. Defaults to 1, which is ideal for standard row indexing.
  • step: The increment between numbers. Defaults to 1.

By nesting ROWS() inside SEQUENCE(), you create a self-adjusting formula that never requires manual updating of ranges.

Step-by-Step Implementation Guide

Follow these steps to implement the solution in your workbook:

  1. Select the Source Table: Identify the Excel Table from which you need the row indices. Ensure it has a defined name (e.g., Table1) by clicking anywhere inside the table and checking the Table Design tab in the ribbon.
  2. Choose the Output Cell: Click on the top-left cell where you want the list of indices to begin. If you have existing data below this cell, ensure there is enough empty space for the array to spill down without causing a #SPILL! error.
  3. Enter the Formula: Type the following formula exactly:
    =SEQUENCE(ROWS(Table1))
    Replace Table1 with the actual name of your table.
  4. Press Enter: The formula will calculate immediately. You should see a column of numbers starting from 1, extending down to match the height of your table.

Handling Older Versions of Excel

If you are not using Microsoft 365 or Excel 2021, dynamic array functionality is unavailable. In these older versions, you must use a different approach involving the ROW and INDIRECT functions, or simply drag the fill handle.

Method 1: Fill Handle (Static) Type 1 in the first cell and 2 in the second cell. Select both cells and drag the fill handle down to the last row of your table. Note that this method is static; if you delete a row in the middle, the sequence will break unless you manually correct it.

Method 2: Legacy Array Formula (Dynamic-ish) If you need a formula-based solution that updates when rows are added/deleted, use:

=ROW(INDIRECT("A1:A"&ROWS(Table1)))
After typing this, you must press Ctrl+Shift+Enter instead of just Enter. This creates a legacy array formula that fills the selected range with the corresponding indices. While functional, it does not offer the same ease of use as the modern SEQUENCE function.

Advanced Customization

You can modify the output of the SEQUENCE function to suit specific needs. For example, if you want the indices to start from 0 instead of 1, use =SEQUENCE(ROWS(Table1),,0). If you need horizontal indices across columns, add a second argument: =SEQUENCE(1, COLUMNS(Table1)).

Additionally, you can combine this with other functions to perform lookups based on these generated indices. For instance, pairing it with XLOOKUP or INDEX/MATCH allows you to extract entire rows of data based on their sequential position.

For more information on managing tables and rows programmatically, see Using VBA to Add Rows and Shift Tables. If you need to sort or filter these indexed results, refer to Excel 2021: How to "fill down" an array?.

Frequently Asked Questions

Why do I get a #SPILL! error?

This error occurs when the cells below or beside your formula are occupied by other data. Excel needs empty space to display the dynamic array. Clear the obstructing cells or move your formula to a location with sufficient blank rows/columns.

Can I use this method with filtered tables?

No, ROWS(Table1) counts all rows in the table, including hidden ones. If you need indices only for visible rows after filtering, you must use a helper column with SUBTOTAL or a VBA macro, as standard array functions ignore filter states.

Does this work in Excel Online?

Yes, provided your Excel Online account is part of a Microsoft 365 subscription that supports dynamic arrays. Older web-based versions may not support the SEQUENCE function.

How do I make the indices reset after deleting rows?

The SEQUENCE formula automatically recalculates whenever the table structure changes. Deleting a row reduces the count returned by ROWS(), so the array will shrink accordingly, maintaining a continuous sequence from 1.

Is there a way to generate unique IDs instead of simple indices?

Simple indices repeat if rows are moved. For unique persistent IDs, consider using a combination of TEXT and NOW() or a GUID generator via VBA, as formula-generated numbers are volatile and change upon recalculation.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More