Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to transpose every 5 or n rows from one column to multiple columns?

doc transpose every 5 rows 1

Supposing, you have long data in column A, and now, you want to transpose every 5 rows from column A to multiple columns, such as transpose A1:A5 to C6:G6, A6:A10 to C7:G7, and so on as following screenshot shown. How could you deal with this task without copying and pasting repeatedly in Excel?

Transpose every 5 or n rows from one column to multiple columns with formula

Transpose every 5 or n rows from one column to multiple columns with VBA code

Transpose every 5 or n rows from one column to multiple columns with Kutools for Excel


Transform every 5 or n rows from one column to multiple columns:

To transform every 5 or n rows from one column to multiple columns, Kutools for Excel's Transform Range utility can help you to solve this job as quickly as you can. It also can help you to transpose a range of data to a single row or column.

doc transpose every 5 rows 10

Kutools for Excel: with more than 200 handy Excel add-ins, free to try with no limitation in 60 days. Download and free trial Now!



In Excel, you can apply the following formula to transpose every n rows from one column to multiple columns, please do as follows:

1. Enter the following formula into a blank cell where you want to put the result, C1, for example, =INDEX($A:$A,ROW(A1)*5-5+COLUMN(A1)), see screenshot:

doc transpose every 5 rows 2

Note: In the above formula, A:A is the column reference that you want to transpose, and A1 is the first cell of the used column, the number 5 indicates the number of columns that your data will locate, you can change them to your need. And the first cell of the list must be located at the first row in the worksheet.

2. Then drag the fill handle right to five cells, and go on dragging the fill handle down to the range of cells until displays 0 , see screenshot:

doc transpose every 5 rows 3


If you can't apply the formula correctly, the following VBA code also can help you.

1. Hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.

2. Click Insert > Module, and paste the following code in the Module Window.

VBA code: Transpose every 5 or n rows from one column to multiple columns:

Public Sub TransposeData()
'updateby Extendoffice 20151207
    Dim xLRow As Long
    Dim xNRow As Long
    Dim i As Long
    Dim xUpdate As Boolean
    Dim xRg As Range
    Dim xOutRg As Range
    Dim xTxt As String
    On Error Resume Next
    xTxt = ActiveWindow.RangeSelection.Address
    Set xRg = Application.InputBox("Please select data range(only one column):", "Kutools for Excel", xTxt, , , , , 8)
    Set xRg = Application.Intersect(xRg, xRg.Worksheet.UsedRange)
    If xRg Is Nothing Then Exit Sub
    If (xRg.Columns.Count > 1) Or _
       (xRg.Areas.Count > 1) Then
        MsgBox "the used range only contain one column", , "Kutools for Excel"
        Exit Sub
    End If
    Set xOutRg = Application.InputBox("please select output range(specify one cell):", "Kutools for Excel", xTxt, , , , , 8)
    If xOutRg Is Nothing Then Exit Sub
    Set xOutRg = xOutRg.Range(1)
    xUpdate = Application.ScreenUpdating
    Application.ScreenUpdating = False
    xLRow = xRg.Rows.Count
    For i = 1 To xLRow Step 5
        xRg.Cells(i).Resize(5).Copy
        xOutRg.Offset(xNRow, 0).PasteSpecial Paste:=xlPasteAll, Transpose:=True
        xNRow = xNRow + 1
    Next
    Application.ScreenUpdating = xUpdate
End Sub

3. After pasting the code, please press F5 key to run it, and a prompt box will pop out to remind you select the column that you want to transpose, see screenshot:

doc transpose every 5 rows 4

4. Then click OK, and select one cell where you want to put the result in another popped out box, see screenshot:

doc transpose every 5 rows 5

5. And click OK, the data in the column has been converted to five columns that you need, see screenshot:

doc transpose every 5 rows 6

Note: In the above code, you can change the number 5 to other number you need.


If you have Kutools for Excel, with its Transform Range utility, you can quickly transpose one column or row to multiple columns and rows.

Kutools for Excel : with more than 300 handy Excel add-ins, free to try with no limitation in 60 days. 

After installing Kutools for Excel, please do as follows:

1. Select the data in the column, and then click Kutools > Range > Transform Range, see screenshot:

doc transpose every 5 rows 7

2. In the Transform Range dialog box, select Single column to range option under the Transform type, and then check Fixed value under the Rows per record, then specify the number of columns that you want to transpose to in the Fixed value box, see screenshot:

doc transpose every 5 rows 8

3. And then click Ok button, in the popped out box, please select a cell to output the result, see screenshot:

doc transpose every 5 rows 9

4. Then click OK button, and your column data has been transposed every 5 rows as following screenshot shown:

doc transpose every 5 rows 6

Download and free trial Kutools for Excel Now !


Kutools for Excel: with more than 200 handy Excel add-ins, free to try with no limitation in 60 days. Download and free trial Now!


Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial.
kte tab 201905

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Maha · 4 months ago
    Thanks alot _/\_ Awesome job with =INDEX($A:$A,ROW(B1)*5-5+COLUMN(B1))
    worked perfectly
  • To post as a guest, your comment is unpublished.
    Arun Balaji VN · 5 months ago
    I tried only the the formula option and it worked great. Till now have been using (Transpose formula with ctrl+shift+enter) but there the disadvantage for we have delete many extra rows. when the rows to be transposed for large in the order of lakhs, then deleting them in excel is either impossible or takes a lot of time.
    this approach made the life easier by only copying the required rows... Thanks
  • To post as a guest, your comment is unpublished.
    Sian · 1 years ago
    This is fricking AWESOME!!! Thank you SO much. Your example was exactly what I needed and it worked beautifully.
  • To post as a guest, your comment is unpublished.
    hamidreza · 1 years ago
    =INDEX($A:$A,ROW(A1)*5-5+COLUMN(A1))
    It was very simple and really useful. Thank you so much
  • To post as a guest, your comment is unpublished.
    Thank · 1 years ago
    It was great! Thank you! You saved me hours of manual work!
  • To post as a guest, your comment is unpublished.
    xplode · 2 years ago
    Thank you so much!
    It was really helpful. :)
  • To post as a guest, your comment is unpublished.
    MTVN · 2 years ago
    What formula to transpose every 5 rows to a single column?
  • To post as a guest, your comment is unpublished.
    hgimongu · 2 years ago
    Hi!

    May I ask you how to add Blank cell delimits records, instead of 5 as the data I am handling hasn't got fix number of rows. I believe the part which I should change may be around this part of the code:

    For i = 1 To xLRow Step 5
    xRg.Cells(i).Resize(5).Copy
    xOutRg.Offset(xNRow, 0).PasteSpecial Paste:=xlPasteAll, Transpose:=True
    xNRow = xNRow + 1

    Best