TOROW Function¶
The TOROW function in Excel is used to convert an array or range into a single row. It takes a multi-dimensional array and returns all values arranged in a single horizontal row. This is particularly useful for flattening data, preparing lists for other functions, or transforming tabular data into a row format.
Key Features of TOROW:¶
- Converts any array or range into a single row.
- Allows control over the scan order (by row or by column).
- Can ignore blanks, errors, or both during conversion.
- Works seamlessly with other dynamic array functions.
- Returns a spilled array that resizes automatically.
Syntax:¶
- array: The array or range to convert to a single row.
- ignore (optional): Specifies what to ignore. Default is 0.
0- Keep all values (default)1- Ignore blanks2- Ignore errors3- Ignore blanks and errors- scan_by_column (optional): Specifies how to read the array. Default is FALSE.
FALSE- Scan the array by row (left to right, then down). This is the default.TRUE- Scan the array by column (top to bottom, then right).
How TOROW Works:¶
- Takes the input array and reads each value in the specified order.
- By default, scans by row (left to right across each row, then moves to the next row).
- If
scan_by_columnis TRUE, scans by column (top to bottom in each column, then moves to the next column). - Optionally filters out blanks and/or errors based on the
ignoreparameter. - Returns all values arranged into a single horizontal row.
Examples:¶
1. Basic Conversion (Scan by Row):¶
Given a range A1:C2 with data:
Result:
(Values are read left to right, row by row)
2. Scan by Column:¶
Using the same range A1:C2:
Result:
(Values are read top to bottom, column by column)
3. Ignore Blanks:¶
Given a range with blanks:
Result:
(Blank cells are removed from the result)
4. Ignore Errors:¶
Given a range with errors:
Result:
(Error values are excluded from the result)
5. Ignore Both Blanks and Errors:¶
Result:
6. Convert Array Constant:¶
Result:
7. Combine with UNIQUE:¶
Result:
8. Flatten for TEXTJOIN:¶
Result:
Notes:¶
TOROWis available in Excel 365 and Excel 2021 or later versions.- The function returns a dynamic spilled array.
- When
ignoreis set to filter values, the resulting array may be smaller than the original. - If the input array is already a single row,
TOROWreturns it unchanged (unless filtering is applied). - Empty results return a
#CALC!error if all values are filtered out.
Applications:¶
- Data Flattening: Convert multi-row data into a single list for analysis.
- List Preparation: Prepare data for functions that require single-row input.
- Data Cleaning: Remove blanks or errors while reshaping data.
- Dynamic Reporting: Combine data from multiple rows into a unified row format.
- Array Manipulation: Transform array shapes for use with other dynamic array functions.
Related Functions:¶
- TOCOL: Converts an array to a single column (vertical equivalent of TOROW).
- WRAPCOLS: Wraps a row or column into multiple columns.
- WRAPROWS: Wraps a row or column into multiple rows.
- VSTACK: Vertically stacks arrays on top of each other.
- HSTACK: Horizontally stacks arrays side by side.
Tip: Use
TOROWcombined withUNIQUEandSORTto quickly generate a sorted list of unique values from a multi-row range:=SORT(UNIQUE(TOROW(A1:C10, 1))).