How to use the TRANSPOSE function
What is the TRANSPOSE function?
The TRANSPOSE function allows you to convert a vertical range to a horizontal range, or vice versa.
What's on this webpage
- Introduction
- Syntax
- How to enter an array formula
- Why do I have to enter the TRANSPOSE function as an array formula?
- Excel 365 users can enter the TRANSPOSE function as a regular formula
- What happens if you transpose a range with the same number of columns and rows?
- How to convert a vertical cell range to constants
- Transpose an array with constants separated vertically
- Two-dimensional arrays
- Transpose a cell range without using a formula
- Get Excel *.xlsx file
1. Introduction
A vertical range is a range with values in one column, a horizontal range has values in one row. You can also transpose a range with more than one column and one row. The following example demonstrates how to transpose a vertical array to a horizontal array.
Array formula in cell D2:H2:
Range B2:B6 has 1 column and 5 rows and it is a vertical range. Use the TRANSPOSE function to convert it to a horizontal range. Shown in the example above.
When is the TRANSPOSE function useful?
The TRANSPOSE function is most useful in scenarios where you want to manipulate arrays which is often the case when using more complicated functions like MMULT function and other Excel functions that take arrays as an input value.
However, simple comparison test between two different arrays may require the TRANSPOSE function based on their layout on the worksheet. Here is an example:
The image above shows two arrays, array1 is in cells C2:F2, and array2 is in C3:G3. To be able to compare these horizontal arrays also with different sizes, we need to transpose one of the arrays to be able to perform the comparison without errors.
Formula in cell C7:
Here is a quick break down:
- TRANSPOSE(C3:G3): The formula in cell C7 transposes array2 in cells C3:G3 from horizontal to vertical.
- C2:F2=TRANSPOSE(C3:G3): The equal sign compares the values despite being in different sizes.
The image above shows the comparisons in cells C7:F11, the grey values above and to the left of C7:F11 show the arrays: array1 and array2
2. Syntax
TRANSPOSE(array)
array | The values you want to transpose. |
=TRANSPOSE(B2:B6) is entered in cell range D2:H2, as an array formula.
3. How to enter an array formula
- Select cell range D2:H2.
- Press with left mouse button on in the formula bar.
- Type: =TRANSPOSE(B2:B6) in the formula bar.
- Press and hold CTRL + SHIFT simultaneously.
- Press Enter once.
- Release CTRL + SHIFT.
If you did this right the formula now begins and ends with a curly bracket. Like this: {=TRANSPOSE(B2:B6)} Don't enter these characters yourself.
3.1 Why do I have to enter the TRANSPOSE function as an array formula?
It returns more than one value, you need to enter it as an array formula if you want to see all values on the worksheet.
3.2 Excel 365 users can enter the TRANSPOSE function as a regular formula
Excel 365 users can now enter dynamic array formulas as regular formulas. Dynamic array formulas expand automatically, this is called spilling.
4. What happens if you transpose a range with the same number of columns and rows?
The picture shows what happens if you transpose a cell range with the same number of rows and columns, in this case, a cell range with 3 columns and 3 rows.
The range size doesn't change but the numbers in the range change positions. The values in the first column (B2:B4) is converted into the first row (F2:H2), the same with the second column (C2:C4) into the second row (F3:H3), and so on.
5. How to converting a vertical cell range to constants
This animated picture shows how to convert the values in a cell range to constants.
What the animated picture doesn't show you is that I am pressing F9 after selecting the cell range B2:B6. These are all the steps:
- Select cell D2.
- Type =
- Select cell range B2:B6.
- Press F9.
The formula bar returns {1;2;3;4;5}. The curly brackets tell you that it is an array. The constants in the array are separated by semicolons. The semicolon tells you that the next value is in the row below. In the example above all values are separated vertically, this is a one-dimensional array.
6. Transpose a vertical array with constants
What happens if we transpose this array? {1;2;3;4;5} Select a cell and type in formula bar: =TRANSPOSE({1;2;3;4;5}) Press F9.
The formula bar shows {1,2,3,4,5}. The comma tells you that the values in the array are separated horizontally.
You can verify this by selecting D2:H2, type =TRANSPOSE({1;2;3;4;5}) in the formula bar and enter it as an array formula.
In other words, the colon tells you that the next value in the array is in the next column. The semicolon tells you that the next value is in the row below.
7. Two-dimensional arrays
Look at this array {1,2,3;4,5,6;7,8,9}. You can now distinguish that this array has 3 columns and 3 rows by looking at the commas and semicolons. The array has values in more than one column and one row. This is a two-dimensional array.
I made this array {1,2,3;4,5,6;7,8,9} from cell range B2:D4, it has 3 columns and 3 rows.
8. Transpose a cell range manually without using a formula
- Select a cell range you want to transpose
- Copy cells (CTRL + c)
- Press with right mouse button on on a destination cell
- Press with left mouse button on "Paste Special..."
- Press with left mouse button on "Transpose"
- Press with left mouse button on OK button
Useful links
TRANSPOSE function - Microsoft
'TRANSPOSE' function examples
First, let me explain the difference between unique values and unique distinct values, it is important you know the difference […]
This post explains how to lookup a value and return multiple values. No array formula required.
Array formulas allows you to do advanced calculations not possible with regular formulas.
Functions in 'Lookup and reference' category
The TRANSPOSE function function is one of 25 functions in the 'Lookup and reference' category.
How to comment
How to add a formula to your comment
<code>Insert your formula here.</code>
Convert less than and larger than signs
Use html character entities instead of less than and larger than signs.
< becomes < and > becomes >
How to add VBA code to your comment
[vb 1="vbnet" language=","]
Put your VBA code here.
[/vb]
How to add a picture to your comment:
Upload picture to postimage.org or imgur
Paste image link to your comment.
Contact Oscar
You can contact me through this contact form