Working with Excel 2010 on Windows XP, limited knowledge regarding VBA (still learning)... Thanks in advance for your help.
Basically what I want to do is define a list in my VBA code which I will then use in a loop to copy and paste columns which headings match my values within my defined list. The results will be pasted to another worksheet.
Here is an example of source data:
<table style="border-collapse: collapse; width: 281pt;" border="0" cellpadding="0" cellspacing="0" width="375"><col style="width: 41pt;" width="55"> <col style="width: 48pt;" span="5" width="64"> <tbody><tr style="height: 15pt;" height="20"> <td class="xl63" style="height: 15pt; width: 41pt;" height="20" width="55">Doug</td> <td class="xl63" style="border-left: medium none; width: 48pt;" width="64">Amy</td> <td class="xl63" style="border-left: medium none; width: 48pt;" width="64">Patrick</td> <td class="xl63" style="border-left: medium none; width: 48pt;" width="64">Kathryn</td> <td class="xl63" style="border-left: medium none; width: 48pt;" width="64">Markus</td> <td class="xl63" style="border-left: medium none; width: 48pt;" width="64">Jen</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl64" style="height: 15pt; border-top: medium none;" height="20">97</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">51</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">3</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">49</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">95</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">38</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl64" style="height: 15pt; border-top: medium none;" height="20">16</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">75</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">38</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">29</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">67</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">30</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl64" style="height: 15pt; border-top: medium none;" height="20">35</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">93</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">30</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">19</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">54</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">87</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl64" style="height: 15pt; border-top: medium none;" height="20">74</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">11</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">89</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">13</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">59</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">37</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl64" style="height: 15pt; border-top: medium none;" height="20">27</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">4</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">90</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">61</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">71</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">66</td> </tr> </tbody></table>
I would then define the list as:
<table style="border-collapse: collapse; width: 41pt;" border="0" cellpadding="0" cellspacing="0" width="55"><col style="width: 41pt;" width="55"> <tbody><tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt; width: 41pt;" height="20" width="55">Doug</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt; border-top: medium none;" height="20">Patrick</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt; border-top: medium none;" height="20">Markus</td> </tr> </tbody></table>
Results:
<table style="border-collapse: collapse; width: 137pt;" border="0" cellpadding="0" cellspacing="0" width="183"><col style="width: 41pt;" width="55"> <col style="width: 48pt;" span="2" width="64"> <tbody><tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt; width: 41pt;" height="20" width="55">Doug</td> <td class="xl65" style="border-left: medium none; width: 48pt;" width="64">Patrick</td> <td class="xl65" style="border-left: medium none; width: 48pt;" width="64">Markus</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl66" style="height: 15pt; border-top: medium none;" height="20">97</td> <td class="xl66" style="border-top: medium none; border-left: medium none;">3</td> <td class="xl66" style="border-top: medium none; border-left: medium none;">95</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl66" style="height: 15pt; border-top: medium none;" height="20">16</td> <td class="xl66" style="border-top: medium none; border-left: medium none;">38</td> <td class="xl66" style="border-top: medium none; border-left: medium none;">67</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl66" style="height: 15pt; border-top: medium none;" height="20">35</td> <td class="xl66" style="border-top: medium none; border-left: medium none;">30</td> <td class="xl66" style="border-top: medium none; border-left: medium none;">54</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl66" style="height: 15pt; border-top: medium none;" height="20">74</td> <td class="xl66" style="border-top: medium none; border-left: medium none;">89</td> <td class="xl66" style="border-top: medium none; border-left: medium none;">59</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl66" style="height: 15pt; border-top: medium none;" height="20">27</td> <td class="xl66" style="border-top: medium none; border-left: medium none;">90</td> <td class="xl66" style="border-top: medium none; border-left: medium none;">71</td> </tr> </tbody></table>
Thanks again for your help.
Basically what I want to do is define a list in my VBA code which I will then use in a loop to copy and paste columns which headings match my values within my defined list. The results will be pasted to another worksheet.
Here is an example of source data:
<table style="border-collapse: collapse; width: 281pt;" border="0" cellpadding="0" cellspacing="0" width="375"><col style="width: 41pt;" width="55"> <col style="width: 48pt;" span="5" width="64"> <tbody><tr style="height: 15pt;" height="20"> <td class="xl63" style="height: 15pt; width: 41pt;" height="20" width="55">Doug</td> <td class="xl63" style="border-left: medium none; width: 48pt;" width="64">Amy</td> <td class="xl63" style="border-left: medium none; width: 48pt;" width="64">Patrick</td> <td class="xl63" style="border-left: medium none; width: 48pt;" width="64">Kathryn</td> <td class="xl63" style="border-left: medium none; width: 48pt;" width="64">Markus</td> <td class="xl63" style="border-left: medium none; width: 48pt;" width="64">Jen</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl64" style="height: 15pt; border-top: medium none;" height="20">97</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">51</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">3</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">49</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">95</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">38</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl64" style="height: 15pt; border-top: medium none;" height="20">16</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">75</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">38</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">29</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">67</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">30</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl64" style="height: 15pt; border-top: medium none;" height="20">35</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">93</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">30</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">19</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">54</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">87</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl64" style="height: 15pt; border-top: medium none;" height="20">74</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">11</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">89</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">13</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">59</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">37</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl64" style="height: 15pt; border-top: medium none;" height="20">27</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">4</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">90</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">61</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">71</td> <td class="xl64" style="border-top: medium none; border-left: medium none;">66</td> </tr> </tbody></table>
I would then define the list as:
<table style="border-collapse: collapse; width: 41pt;" border="0" cellpadding="0" cellspacing="0" width="55"><col style="width: 41pt;" width="55"> <tbody><tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt; width: 41pt;" height="20" width="55">Doug</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt; border-top: medium none;" height="20">Patrick</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt; border-top: medium none;" height="20">Markus</td> </tr> </tbody></table>
Results:
<table style="border-collapse: collapse; width: 137pt;" border="0" cellpadding="0" cellspacing="0" width="183"><col style="width: 41pt;" width="55"> <col style="width: 48pt;" span="2" width="64"> <tbody><tr style="height: 15pt;" height="20"> <td class="xl65" style="height: 15pt; width: 41pt;" height="20" width="55">Doug</td> <td class="xl65" style="border-left: medium none; width: 48pt;" width="64">Patrick</td> <td class="xl65" style="border-left: medium none; width: 48pt;" width="64">Markus</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl66" style="height: 15pt; border-top: medium none;" height="20">97</td> <td class="xl66" style="border-top: medium none; border-left: medium none;">3</td> <td class="xl66" style="border-top: medium none; border-left: medium none;">95</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl66" style="height: 15pt; border-top: medium none;" height="20">16</td> <td class="xl66" style="border-top: medium none; border-left: medium none;">38</td> <td class="xl66" style="border-top: medium none; border-left: medium none;">67</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl66" style="height: 15pt; border-top: medium none;" height="20">35</td> <td class="xl66" style="border-top: medium none; border-left: medium none;">30</td> <td class="xl66" style="border-top: medium none; border-left: medium none;">54</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl66" style="height: 15pt; border-top: medium none;" height="20">74</td> <td class="xl66" style="border-top: medium none; border-left: medium none;">89</td> <td class="xl66" style="border-top: medium none; border-left: medium none;">59</td> </tr> <tr style="height: 15pt;" height="20"> <td class="xl66" style="height: 15pt; border-top: medium none;" height="20">27</td> <td class="xl66" style="border-top: medium none; border-left: medium none;">90</td> <td class="xl66" style="border-top: medium none; border-left: medium none;">71</td> </tr> </tbody></table>
Thanks again for your help.