JNagelvoort
New Member
- Joined
- Feb 13, 2009
- Messages
- 6
I need a macro to shift column data to the top row for a given cell range sharing common data in row A.
I need to get from this:
<table x:str="" style="border-collapse: collapse; width: 384px; height: 288px;" border="0" cellpadding="0" cellspacing="0"><col style="width: 42pt;" span="5" width="56"> <tbody><tr style="height: 13.5pt;" height="18"> <td class="xl24" style="height: 13.5pt; width: 42pt;" width="56" height="18">Name</td> <td class="xl22" style="border-left: medium none; width: 42pt;" width="56">Fruit</td> <td class="xl22" style="border-left: medium none; width: 42pt;" width="56">Meat</td> <td class="xl22" style="border-left: medium none; width: 42pt;" width="56">Dairy</td> <td class="xl23" style="border-left: medium none; width: 42pt;" width="56">Bakery</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl33" style="border-top: medium none; height: 12.75pt;" height="17">Alex</td> <td class="xl24">Apples</td> <td class="xl25" style="border-left: medium none;"> </td> <td class="xl25" style="border-left: medium none;"> </td> <td class="xl26" style="border-left: medium none;"> </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl33" style="border-top: medium none; height: 12.75pt;" height="17">Alex</td> <td class="xl27" style="border-top: medium none;"> </td> <td class="xl28" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl28" style="border-top: medium none; border-left: medium none;">Milk</td> <td class="xl29" style="border-top: medium none; border-left: medium none;"> </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl33" style="border-top: medium none; height: 12.75pt;" height="17">Alex</td> <td class="xl27" style="border-top: medium none;"> </td> <td class="xl28" style="border-top: medium none; border-left: medium none;">Bacon</td> <td class="xl28" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl29" style="border-top: medium none; border-left: medium none;"> </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl33" style="border-top: medium none; height: 12.75pt;" height="17">Alex</td> <td class="xl27" style="border-top: medium none;"> </td> <td class="xl28" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl28" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl29" style="border-top: medium none; border-left: medium none;">Bread</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl33" style="border-top: medium none; height: 12.75pt;" height="17">Bill</td> <td class="xl27" style="border-top: medium none;"> </td> <td class="xl28" style="border-top: medium none; border-left: medium none;">Steak</td> <td class="xl28" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl29" style="border-top: medium none; border-left: medium none;"> </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl33" style="border-top: medium none; height: 12.75pt;" height="17">Bill</td> <td class="xl27" style="border-top: medium none;"> </td> <td class="xl28" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl28" style="border-top: medium none; border-left: medium none;">Eggs</td> <td class="xl29" style="border-top: medium none; border-left: medium none;"> </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl33" style="border-top: medium none; height: 12.75pt;" height="17">Bill</td> <td class="xl27" style="border-top: medium none;"> </td> <td class="xl28" style="border-top: medium none; border-left: medium none;">Chicken</td> <td class="xl28" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl29" style="border-top: medium none; border-left: medium none;"> </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl33" style="border-top: medium none; height: 12.75pt;" height="17">Bill</td> <td class="xl27" style="border-top: medium none;">Oranges</td> <td>
</td> <td class="xl28" style="border-top: medium none;"> </td> <td class="xl29" style="border-top: medium none; border-left: medium none;"> </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl33" style="border-top: medium none; height: 12.75pt;" height="17">Carl</td> <td class="xl27" style="border-top: medium none;"> </td> <td class="xl28" style="border-left: medium none;"> </td> <td class="xl28" style="border-top: medium none; border-left: medium none;">Butter</td> <td class="xl29" style="border-top: medium none; border-left: medium none;"> </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl33" style="border-top: medium none; height: 12.75pt;" height="17">Carl</td> <td class="xl27" style="border-top: medium none;"> </td> <td class="xl28" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl28" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl29" style="border-top: medium none; border-left: medium none;">Cake</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl33" style="border-top: medium none; height: 12.75pt;" height="17">Carl</td> <td class="xl27" style="border-top: medium none;"> </td> <td class="xl28" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl28" style="border-top: medium none; border-left: medium none;">Milk</td> <td class="xl29" style="border-top: medium none; border-left: medium none;"> </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl33" style="border-top: medium none; height: 12.75pt;" height="17">Carl</td> <td class="xl27" style="border-top: medium none;">Bananas</td> <td class="xl28" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl28" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl29" style="border-top: medium none; border-left: medium none;"> </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl33" style="border-top: medium none; height: 12.75pt;" height="17">Carl</td> <td class="xl27" style="border-top: medium none;"> </td> <td class="xl28" style="border-top: medium none; border-left: medium none;">Pork</td> <td class="xl28" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl29" style="border-top: medium none; border-left: medium none;"> </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl33" style="border-top: medium none; height: 12.75pt;" height="17">Carl</td> <td class="xl27" style="border-top: medium none;">Peaches</td> <td class="xl28" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl28" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl29" style="border-top: medium none; border-left: medium none;"> </td> </tr> <tr style="height: 13.5pt;" height="18"> <td class="xl34" style="border-top: medium none; height: 13.5pt;" height="18">Carl</td> <td class="xl30" style="border-top: medium none;"> </td> <td class="xl31" style="border-top: medium none; border-left: medium none;">Chicken</td> <td class="xl31" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl32" style="border-top: medium none; border-left: medium none;"> </td> </tr> </tbody></table>
To this:
<table x:str="" style="border-collapse: collapse;" border="0" cellpadding="0" cellspacing="0" width="373" height="104"><col style="width: 42pt;" span="5" width="56"> <tbody><tr style="height: 13.5pt;" height="18"> <td class="xl26" style="height: 13.5pt; width: 42pt;" width="56" height="18">Name</td> <td class="xl24" style="border-left: medium none; width: 42pt;" width="56">Fruit</td> <td class="xl24" style="border-left: medium none; width: 42pt;" width="56">Meat</td> <td class="xl24" style="border-left: medium none; width: 42pt;" width="56">Dairy</td> <td class="xl25" style="border-left: medium none; width: 42pt;" width="56">Bakery</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl35" style="border-top: medium none; height: 12.75pt;" height="17">Alex</td> <td class="xl26">Apples</td> <td class="xl27" style="border-left: medium none;">Bacon</td> <td class="xl27" style="border-left: medium none;">Milk</td> <td class="xl28" style="border-left: medium none;">Bread</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl35" style="border-top: medium none; height: 12.75pt;" height="17">Bill</td> <td class="xl29" style="border-top: medium none;">Oranges</td> <td class="xl30" style="border-top: medium none; border-left: medium none;">Chicken</td> <td class="xl30" style="border-top: medium none; border-left: medium none;">Eggs</td> <td class="xl31" style="border-top: medium none; border-left: medium none;"> </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl35" style="border-top: medium none; height: 12.75pt;" height="17">Bill</td> <td class="xl29" style="border-top: medium none;"> </td> <td class="xl30" style="border-top: medium none; border-left: medium none;">Steak</td> <td class="xl30" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl31" style="border-top: medium none; border-left: medium none;"> </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl35" style="border-top: medium none; height: 12.75pt;" height="17">Carl</td> <td class="xl29" style="border-top: medium none;">Bananas</td> <td class="xl30" style="border-top: medium none; border-left: medium none;">Chicken</td> <td class="xl30" style="border-top: medium none; border-left: medium none;">Butter</td> <td class="xl31" style="border-top: medium none; border-left: medium none;">Cake</td> </tr> <tr style="height: 13.5pt;" height="18"> <td class="xl36" style="border-top: medium none; height: 13.5pt;" height="18">Carl</td> <td class="xl32" style="border-top: medium none;">Peaches</td> <td class="xl33" style="border-top: medium none; border-left: medium none;">Pork</td> <td class="xl33" style="border-top: medium none; border-left: medium none;">Milk</td> <td class="xl34" style="border-top: medium none; border-left: medium none;"> </td> </tr> </tbody></table>
It would be nice if the shifting would sort the data as well.
I need to get from this:
<table x:str="" style="border-collapse: collapse; width: 384px; height: 288px;" border="0" cellpadding="0" cellspacing="0"><col style="width: 42pt;" span="5" width="56"> <tbody><tr style="height: 13.5pt;" height="18"> <td class="xl24" style="height: 13.5pt; width: 42pt;" width="56" height="18">Name</td> <td class="xl22" style="border-left: medium none; width: 42pt;" width="56">Fruit</td> <td class="xl22" style="border-left: medium none; width: 42pt;" width="56">Meat</td> <td class="xl22" style="border-left: medium none; width: 42pt;" width="56">Dairy</td> <td class="xl23" style="border-left: medium none; width: 42pt;" width="56">Bakery</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl33" style="border-top: medium none; height: 12.75pt;" height="17">Alex</td> <td class="xl24">Apples</td> <td class="xl25" style="border-left: medium none;"> </td> <td class="xl25" style="border-left: medium none;"> </td> <td class="xl26" style="border-left: medium none;"> </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl33" style="border-top: medium none; height: 12.75pt;" height="17">Alex</td> <td class="xl27" style="border-top: medium none;"> </td> <td class="xl28" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl28" style="border-top: medium none; border-left: medium none;">Milk</td> <td class="xl29" style="border-top: medium none; border-left: medium none;"> </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl33" style="border-top: medium none; height: 12.75pt;" height="17">Alex</td> <td class="xl27" style="border-top: medium none;"> </td> <td class="xl28" style="border-top: medium none; border-left: medium none;">Bacon</td> <td class="xl28" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl29" style="border-top: medium none; border-left: medium none;"> </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl33" style="border-top: medium none; height: 12.75pt;" height="17">Alex</td> <td class="xl27" style="border-top: medium none;"> </td> <td class="xl28" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl28" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl29" style="border-top: medium none; border-left: medium none;">Bread</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl33" style="border-top: medium none; height: 12.75pt;" height="17">Bill</td> <td class="xl27" style="border-top: medium none;"> </td> <td class="xl28" style="border-top: medium none; border-left: medium none;">Steak</td> <td class="xl28" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl29" style="border-top: medium none; border-left: medium none;"> </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl33" style="border-top: medium none; height: 12.75pt;" height="17">Bill</td> <td class="xl27" style="border-top: medium none;"> </td> <td class="xl28" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl28" style="border-top: medium none; border-left: medium none;">Eggs</td> <td class="xl29" style="border-top: medium none; border-left: medium none;"> </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl33" style="border-top: medium none; height: 12.75pt;" height="17">Bill</td> <td class="xl27" style="border-top: medium none;"> </td> <td class="xl28" style="border-top: medium none; border-left: medium none;">Chicken</td> <td class="xl28" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl29" style="border-top: medium none; border-left: medium none;"> </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl33" style="border-top: medium none; height: 12.75pt;" height="17">Bill</td> <td class="xl27" style="border-top: medium none;">Oranges</td> <td>
</td> <td class="xl28" style="border-top: medium none;"> </td> <td class="xl29" style="border-top: medium none; border-left: medium none;"> </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl33" style="border-top: medium none; height: 12.75pt;" height="17">Carl</td> <td class="xl27" style="border-top: medium none;"> </td> <td class="xl28" style="border-left: medium none;"> </td> <td class="xl28" style="border-top: medium none; border-left: medium none;">Butter</td> <td class="xl29" style="border-top: medium none; border-left: medium none;"> </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl33" style="border-top: medium none; height: 12.75pt;" height="17">Carl</td> <td class="xl27" style="border-top: medium none;"> </td> <td class="xl28" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl28" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl29" style="border-top: medium none; border-left: medium none;">Cake</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl33" style="border-top: medium none; height: 12.75pt;" height="17">Carl</td> <td class="xl27" style="border-top: medium none;"> </td> <td class="xl28" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl28" style="border-top: medium none; border-left: medium none;">Milk</td> <td class="xl29" style="border-top: medium none; border-left: medium none;"> </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl33" style="border-top: medium none; height: 12.75pt;" height="17">Carl</td> <td class="xl27" style="border-top: medium none;">Bananas</td> <td class="xl28" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl28" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl29" style="border-top: medium none; border-left: medium none;"> </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl33" style="border-top: medium none; height: 12.75pt;" height="17">Carl</td> <td class="xl27" style="border-top: medium none;"> </td> <td class="xl28" style="border-top: medium none; border-left: medium none;">Pork</td> <td class="xl28" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl29" style="border-top: medium none; border-left: medium none;"> </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl33" style="border-top: medium none; height: 12.75pt;" height="17">Carl</td> <td class="xl27" style="border-top: medium none;">Peaches</td> <td class="xl28" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl28" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl29" style="border-top: medium none; border-left: medium none;"> </td> </tr> <tr style="height: 13.5pt;" height="18"> <td class="xl34" style="border-top: medium none; height: 13.5pt;" height="18">Carl</td> <td class="xl30" style="border-top: medium none;"> </td> <td class="xl31" style="border-top: medium none; border-left: medium none;">Chicken</td> <td class="xl31" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl32" style="border-top: medium none; border-left: medium none;"> </td> </tr> </tbody></table>
To this:
<table x:str="" style="border-collapse: collapse;" border="0" cellpadding="0" cellspacing="0" width="373" height="104"><col style="width: 42pt;" span="5" width="56"> <tbody><tr style="height: 13.5pt;" height="18"> <td class="xl26" style="height: 13.5pt; width: 42pt;" width="56" height="18">Name</td> <td class="xl24" style="border-left: medium none; width: 42pt;" width="56">Fruit</td> <td class="xl24" style="border-left: medium none; width: 42pt;" width="56">Meat</td> <td class="xl24" style="border-left: medium none; width: 42pt;" width="56">Dairy</td> <td class="xl25" style="border-left: medium none; width: 42pt;" width="56">Bakery</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl35" style="border-top: medium none; height: 12.75pt;" height="17">Alex</td> <td class="xl26">Apples</td> <td class="xl27" style="border-left: medium none;">Bacon</td> <td class="xl27" style="border-left: medium none;">Milk</td> <td class="xl28" style="border-left: medium none;">Bread</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl35" style="border-top: medium none; height: 12.75pt;" height="17">Bill</td> <td class="xl29" style="border-top: medium none;">Oranges</td> <td class="xl30" style="border-top: medium none; border-left: medium none;">Chicken</td> <td class="xl30" style="border-top: medium none; border-left: medium none;">Eggs</td> <td class="xl31" style="border-top: medium none; border-left: medium none;"> </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl35" style="border-top: medium none; height: 12.75pt;" height="17">Bill</td> <td class="xl29" style="border-top: medium none;"> </td> <td class="xl30" style="border-top: medium none; border-left: medium none;">Steak</td> <td class="xl30" style="border-top: medium none; border-left: medium none;"> </td> <td class="xl31" style="border-top: medium none; border-left: medium none;"> </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl35" style="border-top: medium none; height: 12.75pt;" height="17">Carl</td> <td class="xl29" style="border-top: medium none;">Bananas</td> <td class="xl30" style="border-top: medium none; border-left: medium none;">Chicken</td> <td class="xl30" style="border-top: medium none; border-left: medium none;">Butter</td> <td class="xl31" style="border-top: medium none; border-left: medium none;">Cake</td> </tr> <tr style="height: 13.5pt;" height="18"> <td class="xl36" style="border-top: medium none; height: 13.5pt;" height="18">Carl</td> <td class="xl32" style="border-top: medium none;">Peaches</td> <td class="xl33" style="border-top: medium none; border-left: medium none;">Pork</td> <td class="xl33" style="border-top: medium none; border-left: medium none;">Milk</td> <td class="xl34" style="border-top: medium none; border-left: medium none;"> </td> </tr> </tbody></table>
It would be nice if the shifting would sort the data as well.