How to Convert Multiple Columns into a Single Row in Excel: 2 Methods

Method 1 – Convert Multiple Columns into a Single Row with Formula

You will find the dataset in the sheet named “Dataset”.

Convert Multiple Columns into a Single Row with Formula

Convert these columns to a single row in another sheet “SingleRow

Steps

  • Go to the “SingleRow” sheet and click on Cell A1.

  • Type the following formula:

=OFFSET(Dataset!$B$4,((ROW()-1)*3)+(FLOOR(COLUMN()-1,3)/3),(COLUMN()-1)-(FLOOR(COLUMN()-1,3)))

  • Press Enter.

  • The first data is pasted here.

Convert Multiple Columns into a Single Row with Formula

  • Drag the Fill Handle icon to the right until you get the 0. Remember, 0 means the end of the dataset. You don’t have to include it.

Ways to Convert Multiple Columns into a Single Row in Excel

We onverted multiple columns to a single row in Excel.

Breakdown of the Formula

Dataset!$B$4:  It specifies the sheet name and the range reference you want to use.

(ROW()-1)*3: 3 stands for the row number.

(COLUMN()-1,3)/3:  3 indicates the column number here.

Change these values according to your needs. Based on your rows and columns.


Method 2 – VBA Codes to Convert Multiple Columns into a Single Row

Steps

  • Press Alt+F11 on your keyboard to open the Visual Basic editor.
  • Click on the Insert > Module option.

  • Type the following code:
Sub convert_to_a_single_row()

Dim input_data As Range, output_range As Range

xTitleId = "Convert Multiple Rows to a Single Column"
Set input_data = Application.Selection
Set input_data = Application.InputBox("Select Your Range :", xTitleId, input_data.Address, Type:=8)

Set output_range = Application.InputBox("Enter the Cell where you want to paste:", xTitleId, Type:=8)

Application.ScreenUpdating = False

num_of_rows = input_data.Rows.Count
num_of_columns = input_data.Columns.Count

For i = 1 To num_of_rows
    input_data.Rows(i).Copy output_range
    Set output_range = output_range.Offset(0, num_of_columns + 0)
Next

Application.ScreenUpdating = True

End Sub
  • Save the file.
  • Press Alt+F8 on your keyboard to open the Macro dialog box.
  • Select convert_to_a_single_row.
  • Click Run.
  • Select the range of cells from the dataset (your multiple columns).

VBA Codes to Convert Multiple Columns into a Single Row in Excel

  • Click OK.

VBA Codes to Convert Multiple Columns into a Single Row in Excel

  • Go to the “VBA” sheet and select any cell to start with.
  • Click OK.

VBA Codes to Convert Multiple Columns into a Single Row in Excel

Breakdown of the VBA Code

Set input_data = Application.Selection

Set input_data = Application.InputBox("Select Your Range :", xTitleId, input_data.Address, Type:=8)

This chunk of code takes your input from multiple columns in your dataset.

Set output_range = Application.InputBox("Enter the Cell where you want to paste:", xTitleId, Type:=8)

It takes the input of the cell where you want to convert your multiple columns to a single row.

num_of_rows = input_data.Rows.Count

num_of_columns = input_data.Columns.Count

These codes count the number of rows and columns of your input dataset.

For i = 1 To num_of_rows

    input_data.Rows(i).Copy output_range

    Set output_range = output_range.Offset(0, num_of_columns + 0)

Next

We run a loop to take each value from your dataset and paste them into a cell. After that, it takes the next value and pastes that in the same row but in the next column.


Similar Readings


How to Convert Multiple Columns into Single Column in Excel

Method 1 – Convert Multiple Columns into Single Column Using Formula

Steps

  • Create a new column where you want to paste your multiple columns.
  • Select Cell F5 and type the following formula:

=INDEX($B$4:$D$6,1+INT((ROW(A1)-1)/COLUMNS($B$4:$D$6)),MOD(ROW(A1)-1+COLUMNS($B$4:$D$6),COLUMNS($B$4:$D$6))+1)

  • Press Enter.

How to Convert Multiple Columns into Single Column in Excel

  • Drag the Fill Handle down until you get #REF!.

How to Convert Multiple Columns into Single Column in Excel

  • You don’t have to include the #REF!. It means the end of the dataset.

How to Convert Multiple Columns into Single Column in Excel

Breakdown of the Formula

  • COLUMNS($B$4:$D$6): The COLUMNS function inside the MOD function here returns the total number of columns available in the range ($B$4:$D$6).
  • ROW(A1)-1+COLUMNS($B$4:$D$6): The mixture of ROW and COLUMNS functions here represents the dividend of the MOD
  • MOD(ROW(A1)-1+COLUMNS($B$4:$D$6), COLUMNS($B$4:$D$6))+1: This part represents the column number of the INDEX For the result, the function returns ‘1’.
  • 1+INT((ROW(A1)-1)/COLUMNS($B$4:$D$6)): This is the row number of the INDEX We specify this in the part where the INT function rounds up the resulting value to the integer form.

Method 2 – CONCATENATE Function to Convert Multiple Columns into Single Column

Steps

  • Select Cell E5 and type the following formula:

=CONCATENATE(B5,C5,D5)

How to Convert Multiple Columns into Single Column in Excel

  • Press Enter.

How to Convert Multiple Columns into Single Column in Excel

  • Drag the Fill handle icon over the range of cells E6:E9.

How to Convert Multiple Columns into Single Column in Excel

 


How to Transpose Multiple Rows in Excel

Steps

  • Select and copy the whole dataset.

How to Transpose Multiple Rows in Excel

  • Cick any cell.

How to Transpose Multiple Rows in Excel

  • From the Home tab, you will find the Paste Click on it and select the Transpose (T) command.

How to Transpose Multiple Rows in Excel

After that, it will transpose the multiple rows of your dataset. To know more about this, read: Transpose Multiple Rows in Group to Columns in Excel.


Things to Remember

The Visual Basic code will convert multiple columns with their formatting also.

Make sure to check those functions we used in the formula. Otherwise, it will be difficult to understand if you are unknown to them.


Download Practice Workbook

Download this practice workbook.


Related Articles

Get FREE Advanced Excel Exercises with Solutions!
A.N.M. Mohaimen Shanto
A.N.M. Mohaimen Shanto

A.N.M. Mohaimen Shanto, a B.Sc. in Computer Science and Engineering from Daffodil International University, boasts two years of experience as a Project Manager at Exceldemy. He authored 90+ articles and led teams as a Team Leader, meticulously reviewing over a thousand articles. Currently, he focuses on enhancing article quality. His passion lies in Excel VBA, Data Science, and SEO, where he enjoys simplifying complex ideas to facilitate learning and growth. His journey mirrors Exceldemy's dedication to excellence and... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo