Text to Rows

JAYLO

Board Regular
Joined
Apr 3, 2002
Messages
238
I understand the Text TO Columns function in Excel. Is there a way to do text To Rows?
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
You can do text to columns, then copy the resulting data and Paste Special Transpose.

Maybe that will work. Otherwise, post a sample of your data and the desired result.
 
Upvote 0
You can do text to columns, then copy the resulting data and Paste Special Transpose.

Maybe that will work. Otherwise, post a sample of your data and the desired result.

Here is an example:
I have:
A B C D E
ace 1 2 3 4
spy 3 2 1 1

and want the above converted to:
ace 1
ace 2
ace 3
ace 4
spy 3
spy 2

etc...
Any ideas?
Thanks!
 
Upvote 0
Select the range first and run
Code:
Sub test()
Dim i As Long, ii As Long, a, b(), n As Long
With Selection
    a = .Value
    ReDim b(1 To .Cells.Count, 1 To 2)
    For i = 1 To UBound(a, 1)
        For ii = 2 To UBound(a, 2)
            If a(i, ii) <> "" Then
                n = n + 1
                b(n, 1) = a(i, 1) : b(n, 2) = a(i, ii)
            End If
    Next ii, i
    .Offset(, .Columns.Count + 1).Resize(n, 2).Value = b
End With
End Sub
 
Upvote 0
JAYLO,

Before the macro:


Excel Workbook
ABCDEFGH
1ace1234
2spy3211
3
4
5
6
7
8
Sheet1



After the macro:


Excel Workbook
ABCDEFGH
1ace1234ace1
2spy3211ace2
3ace3
4ace4
5spy3
6spy2
7spy1
8spy1
Sheet1



Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

Press and hold down the 'ALT' key, and press the 'F11' key.

On the 'Insert' menu, click 'Module'.

Copy the below code, and paste it into the Module (on the right pane).


Code:
Option Explicit
Sub MoveData()
Dim NR As Long, i As Long, MyArray As Variant
NR = 1
For i = 1 To Cells(Rows.Count, 1).End(xlUp).Row Step 1
  Cells(i, 1).Copy Range(Cells(NR, 7), Cells(NR + 3, 7))
  MyArray = Range(Cells(i, 2), Cells(i, 5))
  Range(Cells(NR, 8), Cells(NR + 3, 8)) = Application.WorksheetFunction.Transpose(MyArray)
  NR = NR + 4
Next i
End Sub


Then run the "MoveData" macro.


Have a great day,
Stan
 
Upvote 0

Forum statistics

Threads
1,215,324
Messages
6,124,250
Members
449,149
Latest member
mwdbActuary

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