Open In App

How to Transpose Data from Rows to Columns

Last Updated : 19 Feb, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

Microsoft Excel is a leading software program by Microsoft that helps you deal with data. It is very certain that, at times, you might want to arrange and manage your data in a different format. In Excel, “Transposing data” refers to changing rows to columns. If you want to create a table and insert data in rows, you want to display it in columns, or vice versa. Then, the transposing data feature helps you out.

How to Change Rows to Columns in Excel

Transforming rows into columns in Excel offers multiple methods for conversion, including:

  • Utilizing Paste Special
  • Employing Transpose Functions
  • Implementing INDIRECT+ADDRESS
  • Leveraging INDIRECT+ADDRESS from alternate cells
  • Using Excel VBA for automation.

How To Convert Excel Rows to Columns using Paste Special

To change rows to columns in Excel, perform these steps:

Step 1: Press Ctrl + Shift + End to select the whole table

Press Ctrl + Shift + End to pick the whole table quickly. In a spreadsheet, this means all the cells with data.

Screenshot-(194)

Step 2: Press Ctrl + C to Copy the selected cells

To copy the selected cells, press Ctrl + C. You can also right-click on the selected cells and click the “Copy” option from the drop-down menu.

Screenshot-(195)

Step 3: Select an empty cell outside the original data range.

Select a cell that is not in the range of your original data. This way, the copy-and-paste spaces will not overlap. For example, if your original datasheet has 20 rows and 8 columns, then the newly modified table will have 20 columns and eight rows.

Screenshot-(196)

Step 4: Right-click the empty cell, choose Paste Special, then “Transpose.”

Right-click on the selected cell. Select “Paste Special” from the context menu to apply the “Transpose effect.”

Screenshot-(197)

Screenshot-(198)

How To Change Rows To Columns In Excel using the Transpose Function

Step 1: Choose cells for transposed data.

Select the cells where you want the transposed data to appear.

Screenshot-(194)

Step 2: Enter the formula “=TRANSPOSE(A$:C$).”

Input “=TRANSPOSE(A$:C$)” to transpose selected data. where $= Column number

Screenshot-(200)

 

Step 3: Press Ctrl + Shift + Enter for TRANSPOSE.

Type Ctrl + Shift + Enter rather than Enter. This is because TRANSPOSE works with arrays and needs to be entered as an array formula.

Screenshot-(201)

Step 4: Data will transposed in the selected cells

Excel will then transpose the data from rows to columns in the selected cells.

Screenshot-(203)

How to Convert Text in Columns to rows in Excel using INDIRECT+ADDRESS

While working on the Excel sheets, there might be times when you want to convert the text or data that you’ve entered in columns to rows.

Certainly! Converting text from columns to Excel rows using INDIRECT+ADDRESS involves a few steps. This method is helpful when you want to transpose data from columns to rows dynamically.

Step 1: Select the data to transpose

Identify the Range of cells containing the text in columns you want to transpose.

Step 2: Select the destination for transposed data.

Identify the destination Range where you want the transposed data to appear. It should be a range of cells with enough space to accommodate the transposed data.

Step 3: Insert a helper row/column.

Add a new row or column where you want to begin the transposed data. This row or column will help create dynamic references.

Step 4: Use the ADDRESS Function for reference

In the first cell of the new row or column, use the ADDRESS function to show where the original data starts. For example, =ADDRESS(row_num, column_num).

How to convert Excel data in columns to rows using INDIRECT+ADDRESS from other cells

Suppose, for example, you have a list of 8 students with their names and grades they got in 5th standard. Now, you have to separate columns to show the grades for each subject, while one column lists the names.

Here’s how you can convert this data from columns to rows using INDIRECT and ADDRESS functions:

Step 1. Select a starting cell for transposing the data.

Choose a cell where you want to begin transposing the data. Let’s say you pick cell J1.

Step 2. Use the formula “=ADDRESS(2, COLUMN(A2), TRUE)” to get the cell’s address.

Put “=ADDRESS(2, COLUMN(A2), TRUE)” into the cell and Press “Enter” to see the cell’s address.

Note: The first cell in the data set that contains the student’s name can be located using this formula.

Step 3. Get the student’s name using =INDIRECT($J$1)

Retrieve the student’s name using the Excel function INDIRECT concerning cell ($J$1).

Step 4: Copy Formulas in cell and paste it across the row

Copy the formula from the cell and paste it across the row where you want to enter student’s names.

Step 5: Apply steps 2 and 3 to all data you wish to transpose.

For every cell of data you wish to transpose, such as marks in subjects, repeat steps 2 and 3.

Step 6: Drag or copy-paste the formula downward.

Either drag the formula downwards or copy and paste it into the cells below to list all students and their corresponding data.

These steps will convert your Excel data from columns to rows using INDIRECT and ADDRESS functions.

How to Automatically Convert Rows to Columns in Excel VBA

Step 1: Open the Excel with data to transpose

Open the Excel that contains the data you want to transpose.

Step 2: Press Alt + F11 to Open VBA Editor:

Open the VBA Editor in Excel by pressing Alt + F11.

Step 3: Right-click on the window, Click “Insert,” and select “Module.”

To insert a module into the VBA Editor, right-click on a data in the Project Explorer window, select “Insert,” and in the end, choose “Module.” This creates a module for VBA code.

Step 4: Use the VBA Code:

Paste the following VBA code In the module:

Sub TransposeRowsToColumnsAutomatically()

Dim SourceRange As Range

Dim DestinationRange As Range

‘Set the source range (rows) to be transposed.

Set SourceRange = Sheets(“Sheet1”).Range(“A1:C3”) ‘ Change Sheet1 and the range as needed

‘Set the destination range where the transposed data will be placed

Set DestinationRange = Sheets(“Sheet1”).Range(“E1”) ‘ Change Sheet1 and the destination cell as needed

‘Transpose the data

SourceRange.Copy

DestinationRange.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:=False, Transpose:=True

Application.CutCopyMode = False

End Sub

Note: Adjust the `sourceRange` and `destinationRange` variables according to your data. The `Transpose:=True` argument in `PasteSpecial` performs the transposition.

Step 5: Press Alt + F8 to Run the Macro

Close the VBA Editor and run the macro by pressing Alt + F8, selecting “TransposeRowsToColumns,” and clicking “Run.”

Step 6: Check the transposed Destination Range

After running the macro, check the specified destination range to see if the rows have been transposed to columns.

VBA Macro Script to Convert Multiple Rows to Columns in Excel

Step 1: Open Excel with the data you want to change

Start by opening your Excel file containing the data you want to change.

Step 2: Press `Alt + F11` to Open VBA Editor

Press “Alt + F11” to open the VBA Editor, where you can insert code to automate functions.

Step 3: Right-click on the window, Click “Insert,” and select “New Module.”

In the VBA Editor, right-click on any item on the left side (Project Explorer), select “Insert,” and then click “Module.” This creates a space where you can write your VBA code.

Step 4: Write the VBA Code

Copy and paste the provided VBA code into the module. This code helps Excel to convert rows to columns.

Sub TransposeRowsToColumns()

Dim sourceRange As Range

Dim destinationRange As Range

‘Define the source Range (change this to your specific Range)

Set sourceRange = Selection’ Use the currently selected range

‘Define the destination range.

Set destinationRange = sourceRange.Offset(0, sourceRange.Columns.Count + 1)

‘Transpose the data

sourceRange.Copy

destinationRange.PasteSpecial Transpose:=True

‘Clear the clipboard

Application.CutCopyMode = False

End Sub

Step 5: Run the Macro

Close the VBA Editor. Then, press `Alt + F8`, choose “TransposeRowsToColumns,” and click “Run” to execute the macro.

Step 6: Check the Result

After running the macro, check your Excel sheet to see if the rows have been changed to columns as desired.

Conclusion

Excel is one of the most preferred platforms widely used worldwide to manage their data. Among the features offered by Excel, one of the most important is changing rows to columns. There are several methods of doing so, and in this guidebook, we’ve also mentioned the VBA and macro script methods. This article will help you learn everything from the basics to the advanced methods of changing rows to columns.

FAQs On How to Transpose Data from Rows to Columns

Can I convert multiple rows to columns in Excel from another workbook?

Yes, using various methods, you can convert multiple rows to columns in Excel from another workbook. One common method is to use Excel’s built-in functionality, like copying and pasting or using formulas such as the Transpose function and INDIRECT+ADDRESS.

Why is the convert Rows to Columns in Excel not working?

A few reasons why the Rows to Columns in Excel may not work are,

A. To change Excel rows and columns, choose the same amount of empty cells as the ones you want to change. For ten columns and 5 rows, for example, choose 10 and 5 rows.

B. You made a mistake when you copied the data.

Where is the INDIRECT function in Excel found?

First, choose an empty cell → select the “Formulas” tab → go to the “Function Library” group → click the “Lookup & Reference” option drop-down → select the “INDIRECT” function, as shown below.
 



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads