Excel TOCOL Function: Flatten Any Range into a Clean Single Column

The TOCOL function converts any multi-dimensional array into a single vertical column. Whether you’re consolidating scattered data, preparing arrays for processing, or creating clean lists from complex structures, TOCOL transforms any layout into a linear vertical sequence with one simple formula.

Table of Contents

What Does the TOCOL Function Do?

TOCOL takes any array – whether it’s a single row, multiple columns, multiple rows, or a full matrix – and flattens it into a single vertical column. This function is essential for data consolidation, preparing arrays for iteration, creating searchable lists, and building flexible data pipelines that adapt to input dimensions automatically.

Unlike manual copying or complex helper column strategies, TOCOL intelligently handles any array shape and orientation. When combined with other dynamic array functions like TOROW, WRAPROWS, WRAPCOLS, FILTER, and SORT, TOCOL enables sophisticated data transformation workflows that would otherwise require extensive manual work or complex nested formulas.

TOCOL Syntax and Arguments

=TOCOL(array, [ignore], [scan_by_column])
  • array (required): The range or array to convert into a single column. Can be any size or shape – row, column, or matrix.
  • ignore (optional): Specifies which values to ignore during flattening. Options are 0 (no ignoring), 1 (ignore blanks), or 2 (ignore errors). Default is 0.
  • scan_by_column (optional): Determines reading direction. Use FALSE or 0 to read row-by-row (default); use TRUE or 1 to read column-by-column down first, then across.

Key Rules:

  • Output is always a single vertical column (N × 1 array).
  • All values from the input array are preserved (unless ignored via the ignore parameter).
  • TOCOL spills automatically downward as many rows as needed.
  • When ignore=1, blank cells are skipped; when ignore=2, errors are skipped.
  • scan_by_column controls whether data is read across rows first or down columns first.
See also  Excel HSTACK Function: Combine Arrays Side‑by‑Side with Dynamic Spill

Key Behaviors and Important Notes

  • Always produces single column: No matter what you input, TOCOL outputs exactly 1 column with multiple rows.
  • Spill behavior: TOCOL is a dynamic array function that automatically spills downward. If cells below are occupied, you get #SPILL! error.
  • Ignore blanks option: When ignore=1, empty cells within the source array are excluded from the output, resulting in a more compact column.
  • Ignore errors option: When ignore=2, error values like #N/A, #DIV/0!, and #VALUE! are skipped.
  • Scan direction matters: scan_by_column=FALSE reads row 1 left-to-right, then row 2, etc. scan_by_column=TRUE reads column A top-to-bottom, then column B, etc.
  • Input flexibility: TOCOL accepts horizontal ranges, vertical ranges, matrices, or spilled arrays from other functions.
  • Live updates: When source data changes, TOCOL automatically recalculates and adjusts output height.

Basic Examples

Example 1: Flatten a horizontal row

Convert a horizontal list in A1:J1 into a single column:

=TOCOL(A1:J1)

Result: A 10×1 array with all values from the row displayed vertically.

Example 2: Flatten a matrix row-by-row

Convert a 3×4 matrix (A1:D3) into a single column:

=TOCOL(A1:D3)

Result: Row 1 cells (A-D), then row 2 cells (A-D), then row 3 cells (A-D), all in one vertical column (12×1).

Example 3: Flatten column-by-column

Same matrix but read column-by-column instead:

=TOCOL(A1:D3, 0, TRUE)

Result: Column A top-to-bottom (A1, A2, A3), then column B, then column C, then column D (still 12×1, but different order).

Example 4: Flatten and ignore blanks

Convert a range with empty cells, skipping the blanks:

=TOCOL(A1:D20, 1)

Result: Only non-blank values from the range in a single column, skipping empty cells.

Example 5: Flatten and ignore errors

Convert a range containing #N/A or other errors, excluding them:

=TOCOL(A1:D10, 2)

Result: All values except errors flattened into a single column.

Example 6: Clean flatten (ignore both blanks and errors)

Cleanest flattening excluding both blanks and errors:

=TOCOL(A1:D20, 3)

Result: Only valid data values, no blanks or errors, in a single vertical column.

Creating Practical Column Transformations

Consolidate scattered data into single column

Combine multiple ranges from different locations:

=VSTACK(
  TOCOL(Q1_Data),
  TOCOL(Q2_Data),
  TOCOL(Q3_Data),
  TOCOL(Q4_Data)
)

Creates a single consolidated list of all quarterly data for analysis.

Prepare data for FILTER/SEARCH processing

Flatten uneven data into processable format:

=TOCOL(
  FILTER(Source_Data, Source_Data <> ""),
  1
)

Filters out blanks, flattens to a column, ready for further transformation or searching.

Create lookup array for INDEX/MATCH

Convert scattered references into searchable vertical list:

=TOCOL(
  UNIQUE(Source_Range),
  1
)

Removes duplicates and blanks, creates a vertical unique list for vertical lookup functions.

Transpose and flatten combined operation

Flip orientation and flatten simultaneously:

=TOCOL(TRANSPOSE(A1:D10), 1)

Transposes the matrix and immediately flattens to a single column, skipping blanks.

Advanced Function Combinations

TOCOL + WRAPCOLS for matrix reshaping

=WRAPCOLS(
  TOCOL(A1:D20, 1),
  5
)

Flattens the matrix skipping blanks, then wraps into columns of 5 items each.

TOCOL + SORT for ordered column

=TOCOL(
  SORT(A1:D100, 2, 1),
  1
)

Sorts the range by column 2 ascending, flattens to a single column, ignoring blanks.

TOCOL + UNIQUE + FILTER for clean list

=TOCOL(
  UNIQUE(FILTER(A:A, A:A <> "")),
  1
)

Filters out blanks, removes duplicates, flattens unique values into a column.

TOCOL for cross-tabulation consolidation

=VSTACK(
  VSTACK({"Region"}, TOCOL(Pivot_Table[Regions], 1)),
  VSTACK({"Sales"}, TOCOL(Pivot_Table[Values], 1))
)

Flattens pivot table regions and values into comparable columns with headers.

See also  How to use TREND function

TOCOL + SEQUENCE for numbered lists

=HSTACK(
  SEQUENCE(ROWS(TOCOL(A1:D100))),
  TOCOL(A1:D100, 1)
)

Creates sequential numbers alongside flattened data for position tracking.

Multi-stage transformation with TOCOL

=TOCOL(
  WRAPROWS(
    TOCOL(
      FILTER(Raw_Data, Raw_Data <> ""),
      1
    ),
    4
  ),
  1
)

Flattens, wraps into rows, then flattens again – useful for complex reshaping pipelines.

Real-World Applications

Consolidate customer data from multiple regions

Flatten customer lists from scattered sheets:

=VSTACK(
  {"All Customers"},
  TOCOL(
    UNIQUE(
      FILTER(
        VSTACK(
          Region_A_Customers,
          Region_B_Customers,
          Region_C_Customers
        ),
        "" <> VSTACK(
          Region_A_Customers,
          Region_B_Customers,
          Region_C_Customers
        )
      )
    ),
    1
  )
)

Creates a master customer list removing blanks and duplicates across regions.

Product inventory consolidation

Flatten warehouse inventory into searchable list:

=TOCOL(
  UNIQUE(
    FILTER(
      HSTACK(
        Warehouse_A_Items,
        Warehouse_B_Items,
        Warehouse_C_Items
      ),
      "" <> HSTACK(
        Warehouse_A_Items,
        Warehouse_B_Items,
        Warehouse_C_Items
      )
    )
  ),
  1
)

Consolidates inventory from three warehouses into a single clean list.

Survey response compilation

Flatten scattered survey responses into analysis format:

=VSTACK(
  {"Survey Responses"},
  TOCOL(
    FILTER(
      HSTACK(
        Respondent_Names,
        Survey_Responses
      ),
      Survey_Responses <> ""
    ),
    1
  )
)

Creates a single list of valid responses for statistical analysis.

Data validation list creation

Generate dropdown list from multiple sources:

=TOCOL(
  UNIQUE(
    FILTER(
      VSTACK(
        Approved_Items,
        Suggested_Items
      ),
      "" <> VSTACK(
        Approved_Items,
        Suggested_Items
      )
    )
  ),
  1
)

Creates dropdown options from combined and deduplicated sources.

Employee directory consolidation

Flatten organizational data into searchable directory:

=VSTACK(
  {"Company Directory"},
  TOCOL(
    SORT(
      UNIQUE(
        FILTER(
          HSTACK(
            TOCOL(Sales_Team, 1),
            TOCOL(Marketing_Team, 1),
            TOCOL(Operations_Team, 1)
          ),
          "" <> HSTACK(
            TOCOL(Sales_Team, 1),
            TOCOL(Marketing_Team, 1),
            TOCOL(Operations_Team, 1)
          )
        )
      ),
      1, 1
    ),
    1
  )
)

Creates an alphabetized company directory from multiple departments.

Understanding the Ignore Parameter

Ignore Value Behavior Example Input Example Output (Rows)
0 (default) Include everything (blanks and errors) {1, “”, 2, #N/A, 3} 1, “”, 2, #N/A, 3 (5 rows)
1 Ignore blanks only {1, “”, 2, #N/A, 3} 1, 2, #N/A, 3 (4 rows)
2 Ignore errors only {1, “”, 2, #N/A, 3} 1, “”, 2, 3 (4 rows)
3 Ignore both blanks and errors {1, “”, 2, #N/A, 3} 1, 2, 3 (3 rows)

Understanding Scan Direction

The scan_by_column parameter determines how TOCOL reads the input array:

Setting Scan Direction Input (3×3 Matrix) Output Order
FALSE or 0 (default) Row-by-row (left-to-right, then next row) A B C / D E F / G H I A, B, C, D, E, F, G, H, I (rows 1-9)
TRUE or 1 Column-by-column (top-to-bottom, then next column) A B C / D E F / G H I A, D, G, B, E, H, C, F, I (rows 1-9)

Choose scan_by_column based on how you want data ordered in the output column.

TOCOL vs. TOROW: Complementary Functions

Function Output Shape Use Case Example
TOCOL Many rows × 1 column (vertical) Flatten to vertical for lists, searchable arrays, or iteration =TOCOL(A1:D10)
TOROW 1 row × many columns (horizontal) Flatten to horizontal for dashboards, exports, or further reshaping =TOROW(A1:D10)

Common Mistakes and How to Avoid Them

Mistake 1: Forgetting about #SPILL! with tall output

TOCOL can produce very tall columns. If cells below are occupied, spilling fails.

Wrong: Place TOCOL(A1:Z1000) in row 1 with data below row 1000 → #SPILL!

Correct: Place formula in a location with many empty rows below

Mistake 2: Confusing ignore parameter values

Unclear which ignore value does what can lead to unexpected output.

Remember: 1 = ignore blanks; 2 = ignore errors; 3 = ignore both

Mistake 3: Using TOCOL when TOROW is needed

If you need horizontal output, use TOROW, not TOCOL.

See also  How to Calculate Irr in Excel

Wrong thinking: “I want a row” → Use TOROW, not TOCOL

Correct thinking: “I want a column” → Use TOCOL

Mistake 4: Not accounting for scan_by_column impact on order

Row-by-row vs. column-by-column scanning produces different output orders.

Solution: Test both options to verify the correct order for your use case

Mistake 5: Expecting TOCOL to filter automatically

TOCOL flattens but doesn’t automatically remove criteria-based items.

Wrong: =TOCOL(A1:D100) won’t filter by value

Correct: =TOCOL(FILTER(A1:D100, criteria), 1) filters before flattening

Mistake 6: Nested TOCOL when not needed

Multiple TOCOL calls can complicate formulas unnecessarily.

Overcomplicated: =TOCOL(TOCOL(A1:D10))

Simple: =TOCOL(A1:D10)

TOCOL vs. Alternative Methods

Method Pros Cons
TOCOL Formula Simple syntax, handles any array shape, options to ignore blanks/errors, dynamic Requires Microsoft 365, produces tall output that needs space
Manual Copy-Paste + Transpose Works in all Excel versions Tedious, no automatic updates, error-prone
TRANSPOSE Function Works in older Excel, familiar to users Doesn’t ignore blanks/errors, less flexible for complex scenarios
FILTER + Manual Work Works for filtering Doesn’t flatten multi-column data, requires additional steps
Helper Columns + INDEX/SMALL Granular control available Clutters spreadsheet, difficult to maintain, many formulas needed

Availability and Compatibility

TOCOL is available in Microsoft 365 for Windows, Mac, and Excel for the web. It is not available in perpetual versions like Excel 2019, 2016, or earlier. For older Excel versions, use TRANSPOSE, manual methods, or helper column strategies as alternatives.

Tips for Mastering TOCOL

  • Always consider ignore parameter: Usually you’ll want ignore=1 to skip blanks, creating cleaner output.
  • Test scan direction: Verify whether row-by-row or column-by-column scanning produces the order you need.
  • Combine with filtering: Use FILTER before TOCOL to process only relevant data before flattening.
  • Provide space for output: Ensure many empty rows below to avoid #SPILL! errors.
  • Use with WRAPROWS/WRAPCOLS: After flattening to a column, wrap back into your desired layout.
  • Remove duplicates first: Use UNIQUE before TOCOL when deduplication is important.
  • Document your flatten logic: Explain why you’re converting to column format in formula comments.
  • Chain with other array functions: TOCOL is most powerful when combined with TOROW, SORT, FILTER, UNIQUE, and SEQUENCE.

Troubleshooting Guide

Error Cause Solution
#SPILL! Not enough empty rows below for output Move formula to a location with more rows available below, or clear cells in the spill range
#VALUE! Invalid ignore or scan_by_column parameter Verify ignore is 0-3 and scan_by_column is TRUE/FALSE or 0/1
#NAME? Function not recognized Verify Microsoft 365 subscription; update Excel to latest version
#REF! Array reference is invalid or deleted Check that the source range exists and is correctly referenced
Unexpected output order scan_by_column setting doesn’t match expectations Test both FALSE (row-by-row) and TRUE (column-by-column) to get desired order
Blanks or errors in output (unexpected) ignore parameter not set correctly Use ignore=1 to skip blanks, ignore=2 to skip errors, or ignore=3 for both

Performance Considerations

  • Very large arrays: Flattening very large matrices (100K+ cells) can impact performance. Test with realistic data volumes before deployment.
  • Tall output: TOCOL creates vertical arrays that can span thousands of rows. Large output ranges consume memory and may slow rendering.
  • Nested operations: Combining TOCOL with FILTER, SORT, UNIQUE, and other array functions can reduce performance on large datasets.
  • Dependent formulas: Many formulas referencing the TOCOL output can compound performance impact.
  • Dashboard impact: Very tall spilled arrays on a dashboard can affect refresh time and responsiveness.

Advanced Scenarios

Dynamic data consolidation from multiple worksheets

=TOCOL(
        VSTACK(
          TOCOL(Sheet1!A:A, 1),
          TOCOL(Sheet2!A:A, 1),
          TOCOL(Sheet3!A:A, 1)
        ),
        1
      )

Consolidates data from three sheets by flattening each, stacking, then flattening the combined result.

Create searchable master list from scattered sources

=TOCOL(
        UNIQUE(
          FILTER(
            VSTACK(
              TOCOL(Source_A, 1),
              TOCOL(Source_B, 1),
              TOCOL(Source_C, 1)
            ),
            "" <> VSTACK(
              TOCOL(Source_A, 1),
              TOCOL(Source_B, 1),
              TOCOL(Source_C, 1)
            )
          )
        ),
        1
      )

Consolidates data from three sources, removes blanks and duplicates, creates single searchable list.

Matrix transpose with selective flattening

=TOCOL(
        TRANSPOSE(
          FILTER(
            Source_Matrix,
            Source_Matrix <> ""
          )
        ),
        1
      )

Filters matrix for non-blank values, transposes, then flattens into a single column.

Create multi-language glossary list

=TOCOL(
        SORT(
          UNIQUE(
            FILTER(
              VSTACK(
                English_Terms,
                Spanish_Terms,
                French_Terms
              ),
              "" <> VSTACK(
                English_Terms,
                Spanish_Terms,
                French_Terms
              )
            )
          ),
          1, 1
        ),
        1
      )

Consolidates terms from three languages, removes blanks and duplicates, sorts alphabetically into single column.

Complex data transformation pipeline with validation

=TOCOL(
        SORT(
          UNIQUE(
            FILTER(
              VSTACK(
                TOCOL(Current_Data, 1),
                TOCOL(Historical_Data, 1)
              ),
              VSTACK(
                TOCOL(Current_Data, 1),
                TOCOL(Historical_Data, 1)
              ) <> "",
              ISNUMBER(
                VSTACK(
                  TOCOL(Current_Data, 1),
                  TOCOL(Historical_Data, 1)
                )
              )
            )
          ),
          1, 1
        ),
        1
      )

Complex pipeline consolidating current and historical data, filtering for blanks and non-numbers, deduplicating, and sorting.