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 during conversion (see the note on
ignorebelow — Codcel does not filter errors). - 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 errors in Excel. Codcel does not filter errors — this behaves as0.3- Ignore blanks and errors in Excel. Codcel filters blanks only, so this behaves as1.- 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 based on the
ignoreparameter. Codcel does not filter error values. - 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 (Not Filtered in Codcel):¶
Given a range with errors:
Result:
(In Excel this would exclude #N/A and #VALUE!. In Codcel the errors are retained and propagate to the
result. Filter them out with IFERROR before calling TOROW if you need Excel's behaviour.)
5. Ignore Both Blanks and Errors (Blanks Only in Codcel):¶
Result:
(Codcel treats 3 the same as 1. In Excel this would also drop error values.)
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. - Codcel difference: the
ignoreargument filters blanks only.2(ignore errors) is a no-op and3(ignore blanks and errors) drops blanks alone. An out-of-rangeignorevalue is accepted silently and treated as0rather than returning#VALUE!. See Known Function Differences. - 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))).