How to Transpose Non-Contiguous Ranges into One Row in Excel

📅 Feb 03, 2026 📝 Sarah Miller

Manually consolidating disconnected Excel data into a single row is a tedious, error-prone struggle for financial modelers. When mapping standard funding sources-such as venture capital, debt, and operational revenue-scattered across separate tables, traditional copy-paste methods fail to maintain dynamic links.

Fortunately, leveraging a modern array formula grants analysts immediate structural clarity and real-time data flow. As a necessary stipulation, this approach requires Excel 365 to leverage dynamic array behaviors. For example, you can effortlessly bridge non-contiguous ranges like A2:A5 and C2:C5 into one seamless horizontal line. Below, we outline the exact formula syntax to execute this transpose.

How to Transpose Non-Contiguous Ranges into One Row in Excel

In data analysis, we frequently encounter datasets that are fragmented across different columns, rows, or entirely separate areas of a worksheet. While Excel's standard TRANSPOSE function is excellent for turning a single, contiguous block of cells from vertical to horizontal (or vice-versa), it fails when you try to feed it multiple, non-contiguous ranges.

Historically, solving this puzzle required writing complex VBA macros, setting up tedious helper cells, or nesting dozens of INDEX and IF statements. Fortunately, the introduction of modern Excel features-specifically dynamic array functions-has completely transformed how we manipulate arrays. In this comprehensive guide, we will explore how to transpose non-contiguous ranges into a single, continuous row using both modern Excel formulas (Excel 365 and Excel 2021+) and traditional, legacy approaches.

The Modern Approach: Excel 365 & 2021 Dynamic Arrays

If you are using modern Excel, you have access to a suite of functions that make reshaping data incredibly simple. The heavy lifting for our specific problem is performed by combining two primary functions: TOROW and either VSTACK or HSTACK.

1. The TOROW and VSTACK Method

To consolidate different vertical or horizontal ranges and flatten them into a single row, we first stack them together and then pass that consolidated array to the TOROW function.

Let's say you have three non-contiguous ranges containing product IDs that you want to list horizontally in a single row:

  • Range 1: A2:A5 (e.g., North Region products)
  • Range 2: C2:C5 (e.g., South Region products)
  • Range 3: E2:E5 (e.g., West Region products)

The formula to combine these into one row is:

=TOROW(VSTACK(A2:A5, C2:C5, E2:E5))

How It Works:

  1. VSTACK(A2:A5, C2:C5, E2:E5): This vertically stacks the three independent arrays into a single, virtual vertical column of 12 cells.
  2. TOROW(...): This takes the newly stacked vertical column and flattens it into a single horizontal row, reading from top to bottom.

2. Controlling the Output: HSTACK vs. VSTACK

The choice between VSTACK (Vertical Stack) and HSTACK (Horizontal Stack) inside TOROW dictates the sequence in which your data is read and placed into the final row. This is particularly important when working with multi-column non-contiguous ranges.

Consider two 2x2 non-contiguous tables: A2:B3 and D2:E3.

  • If you use =TOROW(VSTACK(A2:B3, D2:E3)), Excel stacks them vertically, then flattens them row-by-row. The output sequence will be: [A2, B2, A3, B3, D2, E2, D3, E3].
  • If you use =TOROW(HSTACK(A2:B3, D2:E3)), Excel stacks them side-by-side first. The output sequence becomes: [A2, B2, D2, E2, A3, B3, D3, E3].

You can also use the second argument of the TOROW function to change the scan direction. By default, TOROW scans row-by-row. If you want to scan column-by-column, you can configure the formula like this:

=TOROW(VSTACK(A2:B3, D2:E3), , TRUE)

The TRUE argument forces Excel to scan the stacked array by column rather than by row, offering complete control over the layout of your output data.

Handling Empty Cells and Errors

One common issue when consolidating disjointed datasets is the presence of empty cells or error values (like #N/A or #DIV/0!) within your ranges. By default, TOROW will convert empty cells into 0 and carry over any errors, which ruins the presentation of your dashboard or report.

To solve this, use the second argument (ignore) of the TOROW function:

=TOROW(VSTACK(A2:A5, C2:C5, E2:E5), 1)

The ignore parameter accepts the following values:

Value Behavior Use Case
0 (or omitted) Keep all values Standard default transposing.
1 Ignore empty cells Skip blank spaces in your non-contiguous source ranges.
2 Ignore error values Skip formula errors in the source ranges.
3 Ignore both empty cells and errors Cleanest consolidation; filters out all noise from your source ranges.

By using 3 as the second argument, you ensure your final row is compact, clean, and free of unnecessary zeroes or frustrating error warnings:

=TOROW(VSTACK(A2:A5, C2:C5, E2:E5), 3)

The Legacy Approach: Excel 2019 and Earlier

If you or your stakeholders are working on older versions of Excel that do not support dynamic array functions like TOROW or VSTACK, you cannot rely on simple spill formulas. Instead, you must use a combination of index-matching and mathematical structures to fetch values from non-contiguous cells sequentially.

Using INDEX and Nested IFs

To map cells from non-contiguous locations to a single continuous row, you can write a formula that counts the columns of your destination cells and dynamically shifts the source range it pulls from.

Suppose you want to combine Range 1 (A2:A5 - 4 cells) and Range 2 (C2:C5 - 4 cells) horizontally starting at cell G2. Drag this formula to the right across 8 cells:

=IF(COLUMN(A1)<=4, INDEX($A$2:$A$5, COLUMN(A1)), INDEX($C$2:$C$5, COLUMN(A1)-4))

How this legacy formula works:

  1. COLUMN(A1): Acts as a dynamic counter. In the first column where you place the formula, it returns 1. As you drag it to the right, it turns to 2, 3, 4, 5, etc.
  2. The logical test (COLUMN(A1)<=4): Checks if the counter is still pointing within the boundaries of the first range (which is 4 cells long).
  3. True action (INDEX($A$2:$A$5, COLUMN(A1))): Pulls from the first range as long as the column counter is 4 or less.
  4. False action (INDEX($C$2:$C$5, COLUMN(A1)-4)): Once the counter hits 5, the formula subtracts 4 (the size of the first range) to reset the index pointer to 1 for the second range, seamlessly pulling the first element of C2:C5.

While this method works, it requires manually calculating the size of each range in the formula logic. If you change the size of your ranges, you will have to rewrite parts of the formula, making it far less scalable than the modern dynamic array system.

Comparing Methods: At a Glance

Method Excel Version Pros Cons
TOROW + VSTACK 365 / 2021+ Incredibly clean, fully dynamic, auto-spills, handles empty spaces natively. Not backward compatible with older Excel versions.
TOROW + HSTACK 365 / 2021+ Perfect for consolidating wide, non-adjacent matrices or records. Requires understanding of scanning directions (row vs. column).
INDEX + Nested IFs All Versions Works on legacy installations of Excel. Requires manual adjustments; cumbersome to build for more than two or three ranges; does not auto-spill.

Conclusion

Transposing non-contiguous ranges into a single, cohesive row used to be one of those tedious tasks that made Excel users dread reporting day. With the release of TOROW, VSTACK, and HSTACK, Excel has made this complex layout manipulation straightforward. You can easily merge distinct tables, skip blanks or errors instantly, and maintain a fully dynamic sheet that updates automatically when your source data changes.

For organizations stuck on older software, the legacy INDEX and COLUMN solution provides a robust, formula-based alternative that ensures cross-version compatibility. Whichever method fits your workspace, you are now equipped to conquer disjointed datasets with ease!

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.