Hello Mr Excel forum. A friend recommended me this forum.
So, I have a list of data like this:
<tbody>
</tbody>
What I'd like to do is where a Variety has more than one Country of Origin listed, create a new row for each country of origin so the list then looks like:
<tbody>
</tbody>
Obviously I can do this using text to columns and transpose but typically I'm dealing with much bigger sheets where being able to do this automatically is a big time saving.
The column with commas in it can vary in position so I'd like this to work on the cell/column that is selected.
Ideally I'd like it to work it's way down the sheet expanding out every comma separated list in the selected column in this fashion but even something that worked on the current cell would be handy.
I think roughly I need to split the cell into an array using the comma as a seperator, possibly scrub the spaces from the text, copy the row as many times as there are things in this array (using ubound?) and then transpose the array into an area starting at the selected row and going down as far as there are things in the array but a bit lost with actual implementation.
I am having a look using Google and not finding anyone with exactly the same problem so hope this isn't a duplicate.<style type="text/css">
table.tableizer-table {
border: 1px solid #CCC; font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
.tableizer-table td {
padding: 4px;
margin: 3px;
border: 1px solid #ccc;
}
.tableizer-table th {
background-color: #104E8B;
color: #FFF;
font-weight: bold;
}
</style>
So, I have a list of data like this:
Type | Variety | Country of Origin | Price |
---|---|---|---|
Apple | Cox's | UK, South Africa, Spain | £1.20 |
Apple | Pink Lady | South Africa, Zimbabwe | £1.30 |
Apple | Granny Smith | UK, France | £1.20 |
Orange | Blood | Spain, South Africa | £1.30 |
Orange | Tangerine | Spain, France | £1.40 |
Banana | Bendy | South Africa, Zimbabwe | £1.20 |
<tbody>
</tbody>
What I'd like to do is where a Variety has more than one Country of Origin listed, create a new row for each country of origin so the list then looks like:
Type | Model | Country of Origin | Price |
---|---|---|---|
Apple | Cox's | UK | £1.20 |
Apple | Cox's | South Africa | £1.20 |
Apple | Cox's | Spain | £1.20 |
Apple | Pink Lady | South Africa, Zimbabwe | £1.30 |
Apple | Granny Smith | UK, France | £1.20 |
Orange | Blood | Spain, South Africa | £1.30 |
Orange | Tangerine | Spain, France | £1.40 |
Banana | Bendy | South Africa, Zimbabwe | £1.20 |
<tbody>
</tbody>
Obviously I can do this using text to columns and transpose but typically I'm dealing with much bigger sheets where being able to do this automatically is a big time saving.
The column with commas in it can vary in position so I'd like this to work on the cell/column that is selected.
Ideally I'd like it to work it's way down the sheet expanding out every comma separated list in the selected column in this fashion but even something that worked on the current cell would be handy.
I think roughly I need to split the cell into an array using the comma as a seperator, possibly scrub the spaces from the text, copy the row as many times as there are things in this array (using ubound?) and then transpose the array into an area starting at the selected row and going down as far as there are things in the array but a bit lost with actual implementation.
I am having a look using Google and not finding anyone with exactly the same problem so hope this isn't a duplicate.<style type="text/css">
table.tableizer-table {
border: 1px solid #CCC; font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
.tableizer-table td {
padding: 4px;
margin: 3px;
border: 1px solid #ccc;
}
.tableizer-table th {
background-color: #104E8B;
color: #FFF;
font-weight: bold;
}
</style>