You are on page 1of 1

Sub SplitColumn()

'Updateby20141106
Dim rng As Range
Dim InputRng As Range
Dim OutRng As Range
Dim xRow As Integer
Dim xCol As Integer
Dim xArr As Variant
xTitleId
= "KutoolsforExcel"
Set InputRng = Application.Selection
Set InputRng = Application.InputBox("Range :", xTitleId, InputRng.Address, T
ype: = 8)
xRow
= Application.InputBox("Rows :", xTitleId)
Set OutRng = Application.InputBox("Out put to (single cell):", xTitleId, T
ype: = 8)
Set InputRng = InputRng.Columns(1)
xCol
= InputRng.Cells.Count / xRow
ReDim xArr(1 To xRow, 1 To xCol + 1)
For i = 0 To InputRng.Cells.Count - 1
xValue = InputRng.Cells(i + 1)
iRow = i Mod xRow
iCol = VBA.Int(i / xRow)
xArr(iRow + 1, iCol + 1) = xValue
Next
OutRng.Resize(UBound(xArr, 1), UBound(xArr, 2)).Value = xArr
End Sub

You might also like