Excel Formula for Generating Sequential Numbers with a Prefix

📅 May 14, 2026 📝 Sarah Miller

Manually generating standardized tracking codes for organizational assets is notoriously time-consuming and prone to human error. While standard funding sources-such as capital allocations or departmental budgets-often dictate strict reporting structures, manually typing sequences is highly inefficient.

Fortunately, dynamic formula sequencing grants teams the ability to automate database organization seamlessly, ensuring flawless scaling.

Stipulation: This method requires defining a fixed digit length to maintain uniform character formatting across your dataset.

For example, converting raw digits into structured identifiers like "GRANT-001" prevents formatting overlap. Below, we outline the exact step-by-step formula to merge your custom prefixes with automated sequential numbers.

Excel Formula for Generating Sequential Numbers with a Prefix

Generating standardized, unique identifiers is a foundational task in data management. Whether you are organizing inventory stock-keeping units (SKUs), generating invoice numbers, building customer databases, or creating employee IDs, combining a text prefix with a sequential number sequence is the industry-standard approach. In Microsoft Excel, this process can be automated using dynamic formulas, saving you from tedious manual entry and eliminating human error.

In this guide, we will explore several robust Excel formulas to concatenate prefixes with sequential numbers. We will cover classic methods compatible with older Excel versions, modern dynamic array formulas for Excel 365, techniques for adding leading zeros, and advanced methods that automatically adjust when rows are added or deleted.

The Core Concept of Concatenation in Excel

To build a composite ID, Excel must combine two distinct elements: a static or dynamic text string (the prefix) and a changing numerical value (the sequence). Excel provides two main operators/functions for this task:

  • The Ampersand Operator (&): The simplest and most popular way to join text strings and numbers together.
  • The CONCAT / CONCATENATE Functions: Built-in formulas designed to join multiple text arguments.

Method 1: The Classic & and ROW Formula

If you need a quick, highly compatible solution that works across every version of Excel, combining the ampersand operator with the ROW function is your best option. The ROW function returns the row number of a cell reference. By utilizing a relative cell reference, the number naturally increments as you drag the formula down.

The Basic Formula

="INV-" & ROW(A1)

How it works:

  • "INV-" is your text prefix. Text strings in Excel formulas must always be enclosed in double quotation marks.
  • & joins the text prefix with the output of the next function.
  • ROW(A1) returns the number 1. When you drag this formula down to the next row, Excel automatically adjusts the reference to ROW(A2), returning 2, then ROW(A3) returning 3, and so on.

Method 2: Formatting with Leading Zeros using TEXT

In professional databases, raw sequential numbers like "INV-1" or "INV-12" can cause sorting issues (where "INV-12" might mistakenly sort before "INV-2"). To prevent this, it is standard practice to pad numbers with leading zeros (e.g., "INV-0001", "INV-0012").

To achieve this in Excel, we wrap our sequential generator inside the TEXT function, which allows us to apply custom number formatting.

The Formula with Leading Zeros

="INV-" & TEXT(ROW(A1), "0000")

How it works:

  • ROW(A1) generates our starting number (1).
  • The TEXT function takes that number and applies the format mask "0000". This mask forces Excel to display the number with at least four digits, padding any unused spaces with zeros. Thus, 1 becomes 0001, and 95 becomes 0095.
  • The ampersand joins the prefix to the newly formatted text string, outputting INV-0001.

Method 3: Dynamic Array Sequences (Excel 365 & 2021)

If you are using modern Excel (Microsoft 365 or Excel 2021), you can leverage the powerful SEQUENCE function. Instead of manually dragging formulas down hundreds of rows, a dynamic array formula "spills" the results down your sheet automatically from a single cell entry.

The Dynamic SEQUENCE Formula

="EMP-" & TEXT(SEQUENCE(100, 1, 1, 1), "000")

Syntax of SEQUENCE(rows, [columns], [start], [step]):

  • 100: Generates 100 sequential rows. (You can change this to any number you need).
  • 1: Restricts the sequence to 1 column.
  • 1: The starting value of the sequence.
  • 1: The increment step for each subsequent number.

When you press Enter, this formula instantly generates a list from EMP-001 through EMP-100. If you need to expand your database, you only have to change the first argument (e.g., from 100 to 500).

Method 4: Dynamic Sequence Based on Adjacent Data

A common issue with fixed-length formulas is that they either leave empty sequences or require you to manually drag them down when new rows of data are added. We can make the sequence completely dynamic by combining SEQUENCE with COUNTA, so that IDs are generated only when adjacent data exists.

The Formula

="PRJ-" & TEXT(SEQUENCE(COUNTA(B2:B100), 1, 1, 1), "0000")

How it works:

Assuming your project names or data entries start in cell B2, the COUNTA(B2:B100) function counts how many non-empty cells exist in that range. If you have 15 project names listed, COUNTA returns 15. The SEQUENCE function then dynamically generates exactly 15 sequential IDs (e.g., PRJ-0001 to PRJ-0015). As you type new entries in column B, new sequential IDs will instantly populate in your ID column.

Method 5: Conditional Sequence with Prefix Groups (Advanced)

Sometimes, your prefix is not static but depends on another column's value, and the sequence needs to reset or increment based on that prefix group. For instance, you might have Category "A" and Category "B", and you want sequences like "A-001", "A-002", "B-001", "A-003", "B-002".

We can achieve this using the COUNTIF function with an expanding range reference.

The Formula (Enter in Row 2)

=A2 & "-" & TEXT(COUNTIF($A$2:A2, A2), "000")

How it works:

  • A2 represents the category/prefix cell.
  • $A$2:A2 is an expanding range reference. Note the absolute reference ($) on the first A2 and the relative reference on the second. When dragged down to row 5, this range dynamically grows to $A$2:A5.
  • COUNTIF($A$2:A2, A2) counts how many times the category value in the current row has appeared from the top of the list down to the current row. This creates an independent counter for each unique prefix group.

Quick Summary of Formulas and Outputs

Formula Concept Excel Formula Example Result (Row 1 / First Item)
Basic Concatenation ="ID-" & ROW(A1) ID-1
Formatted Zeros ="SKU-" & TEXT(ROW(A1), "00000") SKU-00001
Dynamic Array (Excel 365) ="BATCH-" & TEXT(SEQUENCE(5), "000") BATCH-001 to BATCH-005 (Spilled)
Date Prefix =TEXT(TODAY(), "YYYYMM") & "-" & TEXT(ROW(A1), "00") 202603-01 (Assuming current year/month)

Pro Tip: Converting Formulas to Static Values

Because these formulas rely on dynamic elements like row coordinates or cell counts, sorting, inserting, or deleting rows in your worksheet can sometimes shift the generated sequential IDs. If you need these IDs to remain permanent once generated (e.g., once an invoice ID is created, it must never change), follow these steps:

  1. Select the range containing your formula-generated IDs.
  2. Copy the range (Press Ctrl + C).
  3. Right-click the selected range and choose Paste Special.
  4. Click Values (or use the shortcut icon with "123") and press OK.

This replaces the dynamic formulas with static text strings, preserving your unique sequences indefinitely.

Conclusion

Concatenating prefixes with sequential numbers in Excel is an essential skill that streamlines data tracking and structures your files. By mastering basic operators like &, formatting functions like TEXT, and advanced arrays like SEQUENCE, you can build self-maintaining spreadsheets tailored to any business requirement.

Disclaimer:
The documents and templates provided on this page are for informational and illustrative purposes only. They do not constitute professional, legal, or financial advice, and should not be relied upon as such. Because individual circumstances and regulatory requirements vary, these materials may not be suitable for your specific needs. We recommend consulting with a qualified professional before adapting or using any of these examples for official or commercial purposes.