Reformatting data

Viski

New Member
Joined
Oct 26, 2017
Messages
4
Hi all, I need to transpose my horizontal data to a vertical format:

i.e.
B145 B266 B360 B325 B445 B710

<tbody>
</tbody>

into

B145
B266
B360
B325
B445
B710

<colgroup><col><col></colgroup><tbody>
</tbody>

Normal transpose function won't work (it places the numbers on the next row) and have looked at =INDIRECT and =INDEX but haven't been able to sort it.

Any ideas? Thanks.
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Try this...
A​
B​
C​
D​
E​
F​
G​
H​
I​
J​
K​
L​
1​
B1
45​
B2
66​
B3
60​
B3
25​
B4
45​
B7
10​
2​
3​
into
4​
B145
5​
B266
6​
B360
7​
B325
8​
B445
9​
B710
A4=INDEX(A$1:L$1,,ROWS($A$1:A1)*2-1)
copied down and across
(note this will only work for 2-entry "sets")
 
Upvote 0
Here's a macro solution you can try. First select the data (A1:L1), then run the macro. Reformatted data are in A3:B8.
Excel Workbook
ABCDEFGHIJKL
1B145B266B360B325B445B710
2
3B145
4B266
5B360
6B325
7B445
8B710
Sheet2



Code:
Sub ViskiReformat()
'first select the data to be reformatted, then run this macro
Dim R As Range, Vin As Variant, Vout As Variant
Set R = Selection  'assumed to be a contiguous cells in a single row
Vin = R.Value
ReDim Vout(1 To UBound(Vin, 2), 1 To 2)
For i = 1 To UBound(Vin, 2)
    If i Mod 2 <> 0 Then
        Vout(i, 1) = Vin(1, i)
    Else
        Vout(i - 1, 2) = Vin(1, i)
    End If
Next i
Application.ScreenUpdating = False
'reformat 2 rows below selection, in first 2 columns of selection
With R(1).Offset(2, 0).Resize(UBound(Vout, 1), 2)
    .Value = Vout
    .SpecialCells(xlCellTypeBlanks).Delete
End With
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Try this...
A​
B​
C​
D​
E​
F​
G​
H​
I​
J​
K​
L​
1​
B1
45​
B2
66​
B3
60​
B3
25​
B4
45​
B7
10​
2​
3​
into
4​
B145
5​
B266
6​
B360
7​
B325
8​
B445
9​
B710

<tbody>
</tbody>

A4=INDEX(A$1:L$1,,ROWS($A$1:A1)*2-1)
copied down and across
(note this will only work for 2-entry "sets")


I'm not sure how you reply here but thanks to both of you - i never would've worked that out in a million years!!
 
Upvote 0

Forum statistics

Threads
1,216,075
Messages
6,128,659
Members
449,462
Latest member
Chislobog

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