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.

How to Transpose Data from Rows to Columns

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 Transpose Data from Rows to Columns

Similar Reads

How to Change Rows to Columns in Excel

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

How To Convert Excel Rows to Columns using Paste Special

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

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

Step 1: Choose cells for transposed data....

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. 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....

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....

How to Automatically Convert Rows to Columns in Excel VBA

Step 1: Open the Excel with data to transpose...

VBA Macro Script to Convert Multiple Rows to Columns in Excel

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

How to Transpose Data from Rows to Columns – FAQs

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

Contact Us