split wrapped cell serial numbers into new lines and allocate description

cr7

New Member
Joined
Jan 7, 2013
Messages
23
Hi , have a major problem here with some badly formatted data.

So I have a description of an item and then the item has multiple references against it i.e order reference - these are all on separate lines in the same row!! wrap texted!! really annoying and bad formatting

example table
description
blue
1003
1005
1006
yellow
2550
3440
4444

<tbody>
</tbody>


So the issue I have is I cant do vlookup as I want to put this data in the following format

blue
1003
blue
1005
blue
1006

<tbody>
</tbody>

so each line item has 1 cell, one item reference and 1 description

Is this even possible in excel?

Many thanks in advance this is doing my head in!

cheers
 
Last edited:
AWESOME!!

only issue I see now is that I have 4 columns actually not just A and B therefore the script is overwriting my clumns c and d?

can we get the data to populate in columns e and f?

so I would want all 4 columns to populate rather than the 2?

sorry probably a rookie question tried tweaking the code got errors :(

If you want the result in columns e and f, change "4" and "3" in the code above to "6" and "5", resp.
If there are further columns to process, please show us one row of data with all the columns and the desired layout.
 
  • Like
Reactions: cr7
Upvote 0

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
If you want the result in columns e and f, change "4" and "3" in the code above to "6" and "5", resp.
If there are further columns to process, please show us one row of data with all the columns and the desired layout.


descsncostquantity
blue

1003
1004
1005
$553
yello2005
2006
2007
$333

<tbody>
</tbody>

so I would want the cost to fill down 3 times and also the quantity to fill down 3 times in the same way as the description

hope this is clear

many thanks appreciate the help here
 
Upvote 0
Try this:

Code:
Sub Sep()
Dim c As Range
    For Each c In Range("b2", Range("b" & Rows.Count).End(xlUp))
        x = Split(c, Chr(10))
            For i = 0 To UBound(x)
                Cells(2 + y + i, 7) = x(i)
                Cells(2 + y + i, 6) = Cells(2 + k, 1)
                Cells(2 + y + i, 8) = Cells(2 + k, 3)
                Cells(2 + y + i, 9) = Cells(2 + k, 4)
                
            Next
            y = y + i: k = k + 1
    Next
End Sub

Excel Workbook
ABCDEFGHI
1descriptioncostquantity
2blue100310041005$553blue1003$553
3yellow255034404444$665blue1004$553
4blue1005$553
5yellow2550$665
6yellow3440$665
7yellow4444$665
Sheet1
 
  • Like
Reactions: cr7
Upvote 0
strange my results are not splitting the B column

The cause of the difference can be that I separated the strings in cells in column B with soft returns (Alt + J). Try this:

Code:
Sub Sep()
Dim c As Range
    For Each c In Range("b2", Range("b" & Rows.Count).End(xlUp))
         c = Trim(c)
         x = Split(c)
            For i = 0 To UBound(x)
                Cells(2 + y + i, 7) = x(i)
                Cells(2 + y + i, 6) = Cells(2 + k, 1)
                Cells(2 + y + i, 8) = Cells(2 + k, 3)
                Cells(2 + y + i, 9) = Cells(2 + k, 4)
                
            Next
            y = y + i: k = k + 1
    Next
End Sub
 
  • Like
Reactions: cr7
Upvote 0
The cause of the difference can be that I separated the strings in cells in column B with soft returns (Alt + J). Try this:

Code:
Sub Sep()
Dim c As Range
    For Each c In Range("b2", Range("b" & Rows.Count).End(xlUp))
         c = Trim(c)
         x = Split(c)
            For i = 0 To UBound(x)
                Cells(2 + y + i, 7) = x(i)
                Cells(2 + y + i, 6) = Cells(2 + k, 1)
                Cells(2 + y + i, 8) = Cells(2 + k, 3)
                Cells(2 + y + i, 9) = Cells(2 + k, 4)
                
            Next
            y = y + i: k = k + 1
    Next
End Sub

Perfect!!

Thank you very much, really appreciate the help with this!
 
Upvote 0

Forum statistics

Threads
1,215,065
Messages
6,122,945
Members
449,095
Latest member
nmaske

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