Excel Text to row

gavink

New Member
Joined
Dec 9, 2009
Messages
13
Hi

Require excel formula to convert column D order no to each and new row.

Input is "From" worksheet to output " To" worksheet.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Hi mrshI9898

Pls refer pictures enclosed.
 

Attachments

  • To worksheet 1.PNG
    To worksheet 1.PNG
    42.8 KB · Views: 9
  • From worksheet.PNG
    From worksheet.PNG
    32.3 KB · Views: 10
  • To worksheet 2.PNG
    To worksheet 2.PNG
    46.6 KB · Views: 9
Upvote 0
Thanks, try this.

VBA Code:
Sub Macro1()

Dim ws As Worksheet
Dim ws2 As Worksheet
Dim rownum As Long
Dim rownum2 As Long
Dim colnum As Long

rownum = 2
rownum2 = 2
Set ws = Sheets("From")
Set ws2 = Sheets("To")

ws.Rows("1").Copy ws2.Rows("1")

    ws.Columns("D:D").Copy ws.Columns("AA:AA")
    ws.Columns("D:D").TextToColumns Destination:=ws.Range("D1"), DataType:=xlDelimited, _
        TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
        Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
        :="/", FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1)), _
        TrailingMinusNumbers:=True
        
Do Until ws.Cells(rownum, 1).Value = ""
    colnum = 5
        Do Until ws.Cells(rownum, colnum) = ""
            ws2.Cells(rownum2, 1) = ws.Cells(rownum, 1)
            ws2.Cells(rownum2, 2) = ws.Cells(rownum, 2)
            ws2.Cells(rownum2, 3) = ws.Cells(rownum, 3)
            ws2.Cells(rownum2, 4) = ws.Cells(rownum, colnum)
            rownum2 = rownum2 + 1
            colnum = colnum + 1
        Loop
rownum = rownum + 1
Loop

ws.Columns("AA:AA").Copy ws.Columns("D:D")
ws.Columns("E:AA").ClearContents
        
End Sub
 
Upvote 0
*Just realized you said formula... Apologies. Not sure of that myself, hopefully the VBA will do
 
Upvote 0

Forum statistics

Threads
1,215,059
Messages
6,122,918
Members
449,094
Latest member
teemeren

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