VBA & Macro Problems

Convert an Excel Column into Rows of Three with VBA

Maira MehtabMaira Mehtab Dec 2, 2026 869 views

Question details

Automatically rearrange a long Excel column into rows containing three values each.

Convert an Excel Column into Rows of Three with VBA
Product
Microsoft Excel
Device & OS
not provided
Scenario
The user wants to avoid manually transposing small groups from a long column.
Observed behavior
Each consecutive group of three source values should appear across one destination row.
Before you start

The macro below reads column A from row 1 and writes to columns C through E on the active sheet. Make sure the destination area is empty, because the macro overwrites cells there.

Solution 1Recommended

Use a VBA macro to place every three column values in a row

Run this macro in desktop Excel to rearrange the values in column A into columns C through E.

The macro copies values rather than formatting or formulas. Blank cells within the source range keep their positions, and a final group with fewer than three entries remains incomplete.

1
Open the VBA editor

In desktop Excel, open the workbook and select the worksheet containing the source data. Open Developer > Visual Basic.

2
Insert the macro

In the VBA editor, choose Insert > Module and paste this code: Sub ColumnToRowsOfThree() Dim ws As Worksheet Dim lastRow As Long Dim i As Long Set ws = ActiveSheet If Application.WorksheetFunction.CountA(ws.Columns("A")) = 0 Then MsgBox "Column A is empty." Exit Sub End If lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row For i = 1 To lastRow ws.Cells(((i - 1) \ 3) + 1, ((i - 1) Mod 3) + 3).Value = ws.Cells(i, 1).Value Next i End Sub

3
Run the macro

Return to the source worksheet, choose Developer > Macros, select ColumnToRowsOfThree, and click Run. The output starts in C1.

4
Save the workbook

Choose File > Save As and select Excel Macro-Enabled Workbook (.xlsm) if you want to keep the macro for later use.

Use a VBA macro to place every three column values in a row
Check the output area: The macro overwrites its destination cells but does not clear results left over from an earlier, longer run. Clear old output in columns C through E before running it again if necessary.
Rearrange data without a macro

Turn a column into rows of three in WPS Spreadsheet

Use an INDEX formula in WPS Spreadsheet to arrange consecutive column values across three columns without running VBA.

  1. 1. Open the workbook: Open your Excel workbook in WPS Spreadsheet. Place the source values in column A starting at A1 and leave columns C through E empty.
  2. 2. Enter the formula: Select C1 and enter =IFERROR(IF(INDEX($A$1:$A$1000,(ROW()-ROW($C$1))*3+COLUMN()-COLUMN($C$1)+1)="","",INDEX($A$1:$A$1000,(ROW()-ROW($C$1))*3+COLUMN()-COLUMN($C$1)+1)),"").
  3. 3. Fill across and down: Drag the fill handle from C1 across to E1, then select C1:E1 and drag the fill handle down to row 334. This covers up to 1,000 source cells; unused output cells appear blank.
  4. 4. Save the result: Choose File > Save As and save the workbook in XLSX format. To cover more than 1,000 source cells, increase both A1000 references in the formula and fill down far enough for the additional values.
Rearrange source values into groups of three with a formulaOutput updates when source values changeOpen and save Microsoft Excel XLSX filesUse a familiar spreadsheet interface
microsoft office alternative - wps office

Frequently Asked Questions

What happens if the number of values is not divisible by three?

The last destination row contains the remaining one or two values. Clear the destination area first so unused cells do not show old results.

Will the macro copy formulas and formatting?

No. The macro assigns each source cell's value to the destination. It does not copy the source formulas or formatting.

How do I keep the VBA macro in my workbook?

In Excel, choose File > Save As and select Excel Macro-Enabled Workbook (.xlsm). An XLSX file cannot retain VBA macros.

Can I rearrange the values without VBA?

Yes. In WPS Spreadsheet, enter the INDEX formula in C1, fill it across to E1, and then fill down enough rows to cover the source range.