keepcalculator

06 Numbers and Powers

Transpose Multiple Rows into One Column?

Card No. 06·55334 · Updated · Standard formula, shown below

Yes, you can transpose multiple rows into a single column in Excel or Google Sheets using formulas, the TRANSPOSE function, or Power Query (in Excel). This article explains the different methods, when each is appropriate, and how to handle common issues like blank cells and dynamic ranges.

Why Transpose Rows to One Column?

Transposing data means changing its orientation—turning rows into columns or columns into rows. When you have a table where each row contains several values (e.g., a product with multiple tags, a student with several test scores) and you need all those values in a single vertical list, you are effectively “flattening” the data. This is common when preparing data for pivot tables, charts, or database imports that expect one value per row.

Method 1: Using the TRANSPOSE Function

The simplest way to transpose a range is the TRANSPOSE function. In Excel, select the cell where you want the first value to appear, type =TRANSPOSE(A1:C3) (adjusting the range), and press Ctrl+Shift+Enter (in older Excel) or just Enter (in Excel 365). In Google Sheets, you just type =TRANSPOSE(A1:C3) and press Enter. This creates a dynamic array that spills the transposed values. However, this only works if you want to flip the entire range—it won’t combine multiple rows into a single column; it just changes the orientation.

Method 2: Using a Formula to Stack Rows into One Column

To actually combine multiple rows into one column, you need a formula that reads each row’s values and stacks them vertically. In Excel 365 and Google Sheets, you can use the FLATTEN function (Google Sheets) or the TOCOL function (Excel 365). For example, =TOCOL(A1:C3) in Excel returns all values in A1:C3 as a single column. In Google Sheets, =FLATTEN(A1:C3) does the same. These functions read the range row by row by default (you can change the order with an optional argument).

Method 3: Using Power Query (Excel)

Power Query is a powerful data transformation tool in Excel (available in Excel 2016 and later). To transpose multiple rows into one column using Power Query:

  1. Select your data range and go to Data > From Table/Range (create a table if prompted).
  2. In the Power Query editor, select all columns you want to combine.
  3. Go to Transform > Unpivot Columns.
  4. The unpivot operation turns each selected column into two columns: “Attribute” (column name) and “Value” (the data).
  5. Remove the “Attribute” column if you don’t need it.
  6. Sort if needed, then click Close & Load to put the result back into a worksheet.

This method is ideal for large datasets because it handles headers and blank cells gracefully.

Method 4: Using a Simple Formula with INDEX and ROW

If you don’t have access to TOCOL or FLATTEN (e.g., older Excel versions), you can use a formula that references the original range with INDEX and ROW. For example, if your data is in A1:C3 and you want the combined list starting in E1, enter this formula in E1 and drag down:

=INDEX($A$1:$C$3, ROW()-ROW($E$1)+1, COLUMN()-COLUMN($E$1)+1)

But this only works if you want to transpose the range as a block (i.e., 3 rows become 3 columns). To stack rows into one column, you need a more complex formula that calculates row and column positions based on a counter. A common approach is:

=INDEX($A$1:$C$3, INT((ROW()-ROW($E$1))/3)+1, MOD(ROW()-ROW($E$1),3)+1)

Here, 3 is the number of columns. This formula works but requires careful adjustment if your range has different dimensions. It also doesn’t automatically skip blanks.

Method 5: Using VBA (Excel) for a One-Time Conversion

If you need to transpose rows into a single column permanently and don’t want to deal with formulas, you can use a simple VBA macro. Press Alt+F11 to open the VBA editor, insert a new module, and paste a code like:

Sub TransposeRowsToColumn()
    Dim rng As Range
    Dim outCell As Range
    Dim cell As Range
    Set rng = Selection
    Set outCell = Range("E1") ' change as needed
    For Each cell In rng
        If cell.Value <> "" Then
            outCell.Value = cell.Value
            Set outCell = outCell.Offset(1, 0)
        End If
    Next cell
End Sub

This loops through each cell in the selected range and copies non-empty values to a column starting at E1. It’s a quick solution but requires enabling macros.

How to Choose the Right Method

  • Dynamic / live data: Use TOCOL (Excel 365) or FLATTEN (Google Sheets) because they update automatically when the source changes.
  • One-time transformation: Use Power Query (Excel) or copy-paste with transpose (but that flips, not stacks). For stacking, use a formula or VBA.
  • Large datasets: Power Query is more efficient than formulas because it doesn’t recalculate.
  • Older Excel versions: Use the INDEX/MOD formula or VBA.

Common Problems and Solutions

  • Blank cells: TOCOL and FLATTEN include blanks by default. In Excel, use =TOCOL(A1:C3,1) to ignore blanks. In Google Sheets, use =FILTER(FLATTEN(A1:C3), FLATTEN(A1:C3)<>"").
  • #VALUE! error: This often happens when the formula is not entered correctly in older Excel (needs Ctrl+Shift+Enter) or when the range is not valid.
  • Spill range issues: In Excel 365, if the destination cells are not empty, you get a #SPILL! error. Clear the cells below the formula.
  • Numbers stored as text: If your values are left-aligned and not numeric, use the VALUE function to convert them.

Frequently Asked Questions

Can I transpose rows into one column without formulas?

Yes, you can use Power Query in Excel (as described above) or copy-paste with the transpose option, but copy-paste transpose only flips the entire range—it doesn’t stack multiple rows into one column. To stack without formulas, Power Query is the best built-in option.

How do I transpose rows into one column in Google Sheets?

Use the FLATTEN function: =FLATTEN(A1:C3). This will return all values in a single column. To ignore blanks, wrap it with FILTER.

What is the difference between TRANSPOSE and FLATTEN?

TRANSPOSE changes the orientation of the entire range (rows become columns and vice versa) but keeps the same number of cells. FLATTEN (or TOCOL) stacks all values from the range into a single column, reducing the number of rows.

How do I transpose rows into one column in Excel 2016?

In Excel 2016, you don’t have TOCOL. Use Power Query (Data > From Table/Range > Unpivot Columns) or use a formula with INDEX, ROW, and COLUMN as shown in Method 4. VBA is also an option.

Can I transpose rows into one column with a delimiter?

Yes, you can use TEXTJOIN in Excel or Google Sheets to combine values with a delimiter, but that puts them in one cell, not one column. To get a column, use TOCOL/FLATTEN and then split by delimiter if needed.

Why does my TOCOL formula return a #CALC! error?

This error occurs when the function cannot return a result because the range is empty or the ignore argument is invalid. Check that the range contains data and that you used the correct syntax.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →