Transposing Horizontal String

c0087

Board Regular
Joined
Jul 13, 2015
Messages
85
Office Version
  1. 365
Platform
  1. Windows
AB
12 13 14 2 112
9 6 5 14 313
1 3 15 2 614
2 4 6 10 122
1
9
6
5
14
3

I need to transpose the horizontal string in column A to look like the example in column B
Every string in column A has the same number ( in this case 5 different numbers)
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
How about
Fluff.xlsm
AB
1
212 13 14 2 112
39 6 5 14 313
41 3 15 2 614
52 4 6 10 122
61
79
86
95
1014
113
121
133
1415
152
166
172
184
196
2010
2112
Data
Cell Formulas
RangeFormula
B2:B21B2=TEXTSPLIT(TEXTJOIN(" ",,A2:A5),," ")
Dynamic array formulas.
 
Upvote 0
How about
Fluff.xlsm
AB
1
212 13 14 2 112
39 6 5 14 313
41 3 15 2 614
52 4 6 10 122
61
79
86
95
1014
113
121
133
1415
152
166
172
184
196
2010
2112
Data
Cell Formulas
RangeFormula
B2:B21B2=TEXTSPLIT(TEXTJOIN(" ",,A2:A5),," ")
Dynamic array formulas.
Yes, but I just need a space in between each set of 5 (it shrunk it in the example)
 
Upvote 0
Try:
VBA Code:
Sub TransposeData()
    Application.ScreenUpdating = False
    Dim v As Variant, vCell As Variant, arr() As Variant, i As Long, ii As Long, x As Long
    v = Range("A1", Range("A" & Rows.Count).End(xlUp)).Value
    For i = LBound(v) To UBound(v)
        vCell = Split(v(i, 1), " ")
        For ii = LBound(vCell) To UBound(vCell)
            x = x + 1
            ReDim Preserve arr(1 To x)
            arr(x) = vCell(ii)
        Next ii
    Next i
    Range("B1").Resize(x).Value = Application.Transpose(arr)
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
but I just need a space in between each set of 5
In that case
Fluff.xlsm
AB
1
212 13 14 2 112
39 6 5 14 313
41 3 15 2 614
52 4 6 10 122
61
7
89
96
105
1114
123
13
141
153
1615
172
186
19
202
214
226
2310
2412
25
26
Data
Cell Formulas
RangeFormula
B2:B25B2=TEXTSPLIT(TEXTJOIN(" ",,A2:A5&" "),," ")
Dynamic array formulas.
 
Upvote 1
Solution
VBA approach:
VBA Code:
Sub TransposeData()
    Application.ScreenUpdating = False
    Dim v As Variant, vCell As Variant, arr() As Variant, i As Long, ii As Long, x As Long
    v = Range("A1", Range("A" & Rows.Count).End(xlUp)).Value
    For i = LBound(v) To UBound(v)
        vCell = Split(v(i, 1), " ")
        For ii = LBound(vCell) To 4
            x = x + 1
            ReDim Preserve arr(1 To x)
            arr(x) = vCell(ii)
            If ii = 4 Then
                ReDim Preserve arr(1 To x + 1)
                arr(x + 1) = ""
                x = x + 1
            End If
        Next ii
    Next i
    Range("B1").Resize(x).Value = Application.Transpose(arr)
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
VBA approach:
VBA Code:
Sub TransposeData()
    Application.ScreenUpdating = False
    Dim v As Variant, vCell As Variant, arr() As Variant, i As Long, ii As Long, x As Long
    v = Range("A1", Range("A" & Rows.Count).End(xlUp)).Value
    For i = LBound(v) To UBound(v)
        vCell = Split(v(i, 1), " ")
        For ii = LBound(vCell) To 4
            x = x + 1
            ReDim Preserve arr(1 To x)
            arr(x) = vCell(ii)
            If ii = 4 Then
                ReDim Preserve arr(1 To x + 1)
                arr(x + 1) = ""
                x = x + 1
            End If
        Next ii
    Next i
    Range("B1").Resize(x).Value = Application.Transpose(arr)
    Application.ScreenUpdating = True
End Sub
This one also works if wanting to use VBA
 
Upvote 0

Forum statistics

Threads
1,215,076
Messages
6,122,984
Members
449,092
Latest member
Mr Hughes

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top