How to Use the TOROW Function in Google Sheets | Combine Multiple Rows and Columns into a Single Row
What Is the TOROW Function?
The TOROW function converts two-dimensional table data spanning multiple rows and columns into a single horizontal row (a 1D array). It also includes convenient options to exclude blank cells or error values during conversion and to specify the scan direction (row-by-row or column-by-column).
Syntax
=TOROW(array, [ignore], [scan_by_column])
- array: The cell range or array you want to convert into a single row.
- ignore: [Optional] Specifies which types of values to exclude using
0–3(default is0).0: Keep all values (ignore nothing)1: Ignore blank cells2: Ignore error values3: Ignore both blank cells and error values
- scan_by_column: [Optional] Specifies the scan direction (default is
FALSE).FALSE: Scan by row (left to right)TRUE: Scan by column (top to bottom)
Example
Here is an example of arranging the table data in A1:B3 into a single horizontal row starting at cell D1 while ignoring blanks.
Original Table (A1:B3)
| Row | Column A | Column B |
|---|---|---|
| 1 | Apple | Orange |
| 2 | (Blank) | Grape |
| 3 | Peach | Pear |
Result (Enter =TOROW(A1:B3, 1) in cell D1)
| Row | Column D | Column E | Column F | Column G | Column H |
|---|---|---|---|---|---|
| 1 | Apple | Orange | Grape | Peach | Pear |
Common Errors and Notes
#REF!Error (Spill Range Conflict): Because theTOROWfunction expands results to the right, a#REF!error occurs if cells to the right in the output row already contain text or numbers.- Difference Between “Blank” and Empty String
"": When1(ignore blanks) is specified for the second argument, not only completely empty cells but also cells returning""(an empty string) from a formula are ignored as blanks. - Compatibility with Excel: A function with the same name, arguments, and behavior also exists in Microsoft Excel (Microsoft 365 and later), so compatibility is preserved when converting files to Excel.
Frequently Asked Questions
Q. Can I exclude blank cells or errors when converting to a single row with TOROW?
A. Yes. By setting the second argument, ignore, to 1 (ignore blanks), 2 (ignore errors), or 3 (ignore both blanks and errors), they will be excluded automatically.
Q. Can I arrange the single row in vertical (column-by-column) order instead of horizontal (row-by-row) order?
A. Yes. Setting the third argument, scan_by_column, to TRUE reads down the first column from top to bottom, then the second column from top to bottom, and arranges the values in a single horizontal row.