Row sorting problem.Need to place row data into correct columns

TerryChristiansohn

New Member
Joined
Feb 11, 2013
Messages
11
Hello. I only know how to record macro's; nothing else, so I cannot even call myself a newbie. But I need help with data that comes to me all jumbled up. The example below is greatly simplified.

In reality, I need to sort out nearly 600,000 rows of data. Each data row contains 28 column records that need to be sorted within that row. The data is divided into worksheets of up to 25,000 rows each. Functions for this many cells kill my computer's memory, so I would really like to have a macro, or a series of macros to accomplish my task.

1. Each farmer grows certain types of fruit. The farmer's and the farmer's country is in one row; that same row also contains the fruit that the farmer grows.
2. The the types of fruit that farmer grows arrives to me scrambled as per its category.
3. Each fruit has its own category: cherries, berries, citrus, Stone Fruit, apples, melons. Happily, you can tell which category each fruit belongs to, for example, each apple variety is preceded by the string "apples:" in the cell.
4. The fruit needs to be sorted into the correct columns as per the row headers.
5. The fruit needs to stay in the same row, so that we always know which farmer grows what fruit, and which country that fruit has been grown in.
6. The index number, the farmer's name and the country must remain in columns A, B, C.

So this is an example that will, hopefully, clarify my problem.

This is how the data arrives:


[TABLE="width: 1270"]
<tbody>[TR]
[TD]Index
[/TD]
[TD]Grower[/TD]
[TD]Country[/TD]
[TD]tropical[/TD]
[TD]cherries[/TD]
[TD]berries[/TD]
[TD]citrus[/TD]
[TD]Stone Fruit[/TD]
[TD]apples[/TD]
[TD]melons[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Georgia Farms[/TD]
[TD]Georgia[/TD]
[TD]citrus: tangerine[/TD]
[TD]tropical: mango[/TD]
[TD]melons: cantaloupe[/TD]
[TD]berries: Bilberry[/TD]
[TD]stone:Apricots[/TD]
[TD]cherries: Rainier[/TD]
[TD]apples: gravenstein[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Berries n' More[/TD]
[TD]USA[/TD]
[TD]berries: Cape Gooseberry[/TD]
[TD]cherries: Lapin[/TD]
[TD]citrus: tangelo[/TD]
[TD]apples: golden delicious[/TD]
[TD]tropical: banana[/TD]
[TD]stone:Nectarines[/TD]
[TD]melons: Casaba[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Heathcliff Greenhouses Ltd[/TD]
[TD]United Kingdom[/TD]
[TD]tropical: starfruit[/TD]
[TD]berries: Riberry[/TD]
[TD]Peaches[/TD]
[TD]citrus: kumquat[/TD]
[TD]apples: fuji[/TD]
[TD]cherries: Van[/TD]
[TD]melons: Crenshaw[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]Innotec Growers[/TD]
[TD]Canada[/TD]
[TD]cherries: Bing[/TD]
[TD]citrus: orange[/TD]
[TD]apples: gala[/TD]
[TD]tropical: passionfruit[/TD]
[TD]melons: Honeydew[/TD]
[TD]berries: Indian Gooseberry[/TD]
[TD]stone:White peach[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]Best Organic[/TD]
[TD]USA[/TD]
[TD]berries: Riberry[/TD]
[TD]citrus: lime[/TD]
[TD]cherries: lambert[/TD]
[TD]tropical: lichii[/TD]
[TD]plum[/TD]
[TD]melons: Juan Canary[/TD]
[TD]apples: granny smith[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]Toutes Les Fruits[/TD]
[TD]France[/TD]
[TD]berries: Acai[/TD]
[TD]melons: Orange-flesh Honeydew[/TD]
[TD]apples: McIntosh[/TD]
[TD]stone:prune[/TD]
[TD]tropical: longan[/TD]
[TD]cherries: Skeena[/TD]
[TD]citrus: grapefruit[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]Maccedonia di Fruita[/TD]
[TD]Italy[/TD]
[TD]apples: pippin[/TD]
[TD]tropical: pineapple[/TD]
[TD]cherries: Sweetheart[/TD]
[TD]
[/TD]
[TD]citrus: lemon[/TD]
[TD]berries: Blueberry[/TD]
[TD]melons: Pepino[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]Delicious Tropic[/TD]
[TD]Fiji[/TD]
[TD]melons: Persian[/TD]
[TD]tropical: coconut[/TD]
[TD]berries: Black Berry[/TD]
[TD]citrus: Bergamot orange[/TD]
[TD]apples: pink lady[/TD]
[TD]
[/TD]
[TD]cherries: Queen Anne[/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]Small Farmers Club[/TD]
[TD]New Zealand[/TD]
[TD]
[/TD]
[TD]cherries: Black[/TD]
[TD]apples: braeburn[/TD]
[TD]berries: Raspberry[/TD]
[TD]melons: Santa Claus[/TD]
[TD]tropical: cherimola[/TD]
[TD]citrus: Cleopatra Mandarin[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]Certified Organic Fruit Growers[/TD]
[TD]USA[/TD]
[TD]cherries: Choke[/TD]
[TD]tropical: Rambutan[/TD]
[TD]apples: Honeycrisp[/TD]
[TD]melons: Seedless Watermelon[/TD]
[TD]
[/TD]
[TD]berries: Mulberry[/TD]
[TD]citrus: Ponderosa lemon[/TD]
[/TR]
[TR]
[TD]11[/TD]
[TD]Master Gardeners[/TD]
[TD]United Kingdom[/TD]
[TD]tropical: guava[/TD]
[TD]melons: Watermelon[/TD]
[TD]berries: Strawberry[/TD]
[TD]cherries: Maraschino[/TD]
[TD]
[/TD]
[TD]apples: Arkansas Black[/TD]
[TD]citrus: Orangelo[/TD]
[/TR]
[TR]
[TD]12[/TD]
[TD]Mastricht[/TD]
[TD]Neatherlands[/TD]
[TD]citrus: Persian lime[/TD]
[TD]cherries: Morello[/TD]
[TD]berries: Red Mulberry[/TD]
[TD]
[/TD]
[TD]melons: Yellow-Flesh Watermelon[/TD]
[TD]
[/TD]
[TD]Tropical: orange papaya[/TD]
[/TR]
[TR]
[TD]13[/TD]
[TD]Herbs de Bon Sante[/TD]
[TD]France[/TD]
[TD]melons: wintermelon[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]citrus: Palestine sweet lime[/TD]
[TD]berries: Logan Berry[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]14[/TD]
[TD]Belle Tropicale[/TD]
[TD]Tahiti[/TD]
[TD]berries: Lingonberry[/TD]
[TD]
[/TD]
[TD]cherries: North Star[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]citrus: Pompia[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]15[/TD]
[TD]Oceana Farmers[/TD]
[TD]New Zealand[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]citrus: kaffir lime[/TD]
[TD]cherries: Spanish Cherry[/TD]
[TD]berries: Huckleberry[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]16[/TD]
[TD]Mexico Fruitas[/TD]
[TD]Mexico[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]citrus: Limetta[/TD]
[TD]cherries: Tieton[/TD]
[TD]berries: Goji berry[/TD]
[/TR]
[TR]
[TD]17[/TD]
[TD]Northlights Organic[/TD]
[TD]Canada[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]berries: Elderberry[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]18[/TD]
[TD]Eastern Seasonal Specialties[/TD]
[TD]
[/TD]
[TD]apples: Arkansas Black[/TD]
[TD]stone:prune[/TD]
[TD]berries: Cranberry[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]cherries: tart[/TD]
[TD]
[/TD]
[/TR]
</tbody>[/TABLE]

[TABLE="width: 959"]
<tbody>[TR]
[TD="class: xl22"]This is how I need it to be sorted:

[TABLE="width: 1268"]
<tbody>[TR]
[TD]Index[/TD]
[TD]Grower[/TD]
[TD]Country[/TD]
[TD]tropical[/TD]
[TD]cherries[/TD]
[TD]berries[/TD]
[TD]citrus[/TD]
[TD]Stone Fruit[/TD]
[TD]apples[/TD]
[TD]melons[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Georgia Farms[/TD]
[TD]Georgia[/TD]
[TD]tropical: mango[/TD]
[TD]cherries: Rainier[/TD]
[TD]berries: Bilberry[/TD]
[TD]citrus: tangerine[/TD]
[TD]stone:Apricots[/TD]
[TD]apples: gravenstein[/TD]
[TD]melons: cantaloupe[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Berries n' More[/TD]
[TD]USA[/TD]
[TD]tropical: banana[/TD]
[TD]cherries: Lapin[/TD]
[TD]berries: Cape Gooseberry[/TD]
[TD]citrus: tangelo[/TD]
[TD]stone:Nectarines[/TD]
[TD]apples: golden delicious[/TD]
[TD]melons: Casaba[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Heathcliff Greenhouses Ltd[/TD]
[TD]United Kingdom[/TD]
[TD]tropical: starfruit[/TD]
[TD]cherries: Van[/TD]
[TD]berries: Riberry[/TD]
[TD]citrus: kumquat[/TD]
[TD]stone:Peaches[/TD]
[TD]apples: fuji[/TD]
[TD]melons: Crenshaw[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]Innotec Growers[/TD]
[TD]Canada[/TD]
[TD]tropical: passionfruit[/TD]
[TD]cherries: Bing[/TD]
[TD]berries: Indian Gooseberry[/TD]
[TD]citrus: orange[/TD]
[TD]stone:White peach[/TD]
[TD]apples: gala[/TD]
[TD]melons: Honeydew[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]Best Organic[/TD]
[TD]USA[/TD]
[TD]tropical: lichii[/TD]
[TD]cherries: lambert[/TD]
[TD]berries: Riberry[/TD]
[TD]citrus: lime[/TD]
[TD]stone:plum[/TD]
[TD]apples: granny smith[/TD]
[TD]melons: Juan Canary[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]Toutes Les Fruits[/TD]
[TD]France[/TD]
[TD]tropical: longan[/TD]
[TD]cherries: Skeena[/TD]
[TD]berries: Acai[/TD]
[TD]citrus: grapefruit[/TD]
[TD]stone:prune[/TD]
[TD]apples: McIntosh[/TD]
[TD]melons: Orange-flesh Honeydew[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]Maccedonia di Fruita[/TD]
[TD]Italy[/TD]
[TD]tropical: pineapple[/TD]
[TD]cherries: Sweetheart[/TD]
[TD]berries: Blueberry[/TD]
[TD]citrus: lemon[/TD]
[TD]
[/TD]
[TD]apples: pippin[/TD]
[TD]melons: Pepino[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]Delicious Tropic[/TD]
[TD]Fiji[/TD]
[TD]tropical: coconut[/TD]
[TD]cherries: Queen Anne[/TD]
[TD]berries: Black Berry[/TD]
[TD]citrus: Bergamot orange[/TD]
[TD]
[/TD]
[TD]apples: pink lady[/TD]
[TD]melons: Persian[/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]Small Farmers Club[/TD]
[TD]New Zealand[/TD]
[TD]tropical: cherimola[/TD]
[TD]cherries: Black[/TD]
[TD]berries: Raspberry[/TD]
[TD]citrus: Cleopatra Mandarin[/TD]
[TD]
[/TD]
[TD]apples: braeburn[/TD]
[TD]melons: Santa Claus[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]Certified Organic Fruit Growers[/TD]
[TD]USA[/TD]
[TD]tropical: Rambutan[/TD]
[TD]cherries: Choke[/TD]
[TD]berries: Mulberry[/TD]
[TD]citrus: Ponderosa lemon[/TD]
[TD]
[/TD]
[TD]apples: Honeycrisp[/TD]
[TD]melons: Seedless Watermelon[/TD]
[/TR]
[TR]
[TD]11[/TD]
[TD]Master Gardeners[/TD]
[TD]United Kingdom[/TD]
[TD]tropical: guava[/TD]
[TD]cherries: Maraschino[/TD]
[TD]berries: Strawberry[/TD]
[TD]citrus: Orangelo[/TD]
[TD]
[/TD]
[TD]apples: Arkansas Black[/TD]
[TD]melons: Watermelon[/TD]
[/TR]
[TR]
[TD]12[/TD]
[TD]Mastricht[/TD]
[TD]Neatherlands[/TD]
[TD]tropical: orange papaya[/TD]
[TD]cherries: Morello[/TD]
[TD]berries: Red Mulberry[/TD]
[TD]citrus: Persian lime[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]melons: Yellow-Flesh Watermelon[/TD]
[/TR]
[TR]
[TD]13[/TD]
[TD]Herbs de Bon Sante[/TD]
[TD]France
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]berries: Logan Berry[/TD]
[TD]citrus: Palestine sweet lime[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]melons: wintermelon[/TD]
[/TR]
[TR]
[TD]14[/TD]
[TD]Belle Tropicale[/TD]
[TD]Tahiti[/TD]
[TD]
[/TD]
[TD]cherries: North Star[/TD]
[TD]berries: Lingonberry[/TD]
[TD]citrus: Pompia[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]15[/TD]
[TD]Oceana Farmers[/TD]
[TD]New Zealand[/TD]
[TD]
[/TD]
[TD]cherries: Spanish Cherry[/TD]
[TD]berries: Huckleberry[/TD]
[TD]citrus: kaffir lime[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]16[/TD]
[TD]Mexico Fruitas[/TD]
[TD]Mexico[/TD]
[TD]
[/TD]
[TD]cherries: Tieton[/TD]
[TD]berries: Goji berry[/TD]
[TD]citrus: Limetta[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]17[/TD]
[TD]Northlights Organic[/TD]
[TD]Canada[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]berries: Elderberry[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]
[/TD]
[/TR]
[TR]
[TD]18[/TD]
[TD]Eastern Seasonal Specialties[/TD]
[TD]
[/TD]
[TD]
[/TD]
[TD]cherries: tart[/TD]
[TD]berries: Cranberry[/TD]
[TD]
[/TD]
[TD]stone:prune[/TD]
[TD]apples: Arkansas Black[/TD]
[TD]
[/TD]
[/TR]
</tbody>[/TABLE]

[/TD]
[/TR]
</tbody>[/TABLE]
Thank you.

 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

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