Hi All,
I have a large real estate database with a column for Transaction Date (TD) and a column directly adjacent which shows Days on Market (DOM). The TD column is already in chronological order.
For the avoidance of doubt, the portion of the database in question looks like this:
<table x:str="" style="border-collapse: collapse; width: 622pt;" border="0" cellpadding="0" cellspacing="0" width="828"><col style="width: 72pt;" span="2" width="96"> <col style="width: 26pt;" width="34"> <col style="width: 67pt;" width="89"> <col style="width: 48pt;" width="64"> <col style="width: 16pt;" width="21"> <col style="width: 48pt;" width="64"> <col style="width: 16pt;" width="21"> <col style="width: 48pt;" span="2" width="64"> <col style="width: 18pt;" width="24"> <col style="width: 54pt;" width="72"> <col style="width: 18pt;" width="24"> <col style="width: 53pt;" width="71"> <col style="width: 18pt;" width="24"> <tbody><tr style="height: 51pt;" height="68"> <td class="xl23" style="height: 51pt; width: 72pt;" height="68" width="96">SALES PRICE</td> <td class="xl23" style="width: 72pt;" width="96">LIST PRICE</td> <td class="xl23" style="width: 26pt;" width="34">CURR.</td> <td class="xl23" style="width: 67pt;" width="89">DATE SOLD</td> <td class="xl23" style="width: 48pt;" width="64">D.O.M.</td> <td class="xl24" style="width: 16pt;" width="21">
</td> <td class="xl24" style="width: 48pt;" width="64">Days between last sale</td> <td class="xl24" style="width: 16pt;" width="21">
</td> <td class="xl24" style="width: 48pt;" width="64">Avg. DOM by year</td> <td class="xl24" style="width: 18pt;" width="24">
</td> <td class="xl24" style="width: 54pt;" width="72">Sales Freq.per SP Range</td> <td class="xl24" style="width: 18pt;" width="24">
</td> <td class="xl24" style="width: 53pt;" width="71">Qty. of Sales 010104-310109</td> <td class="xl24" style="width: 18pt;" width="24">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl25" style="height: 12.75pt;" x:num="4800000" align="right" height="17">4,800,000</td> <td class="xl25" x:num="5975000" align="right">5,975,000</td> <td class="xl23">US</td> <td class="xl31" x:num="38016" align="right">1-30-2004</td> <td x:num="" align="right">134</td> <td>
</td> <td class="xl27">
</td> <td class="xl26">
</td> <td class="xl26">
</td> <td class="xl26">
</td> <td class="xl28" x:num="">500000</td> <td class="xl23" x:num="">7</td> <td class="xl30" x:num="38352">12-31-2004</td> <td class="xl23" x:num="">2</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl25" style="height: 12.75pt;" x:num="303000" align="right" height="17">303,000</td> <td class="xl25" x:num="310000" align="right">310,000</td> <td class="xl23">CI</td> <td class="xl31" x:num="38093" align="right">4-16-2004</td> <td x:num="" align="right">129</td> <td>
</td> <td class="xl26" x:num="" x:fmla="=D3-D2" align="right">77.0</td> <td class="xl26">
</td> <td class="xl26">
</td> <td class="xl26">
</td> <td class="xl29" style="width: 54pt;" x:num="" width="72">1000000</td> <td class="xl23" x:num="">3</td> <td class="xl30" x:num="38717">12-31-2005</td> <td class="xl23" x:num="">2</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl25" style="height: 12.75pt;" x:num="1275000" align="right" height="17">1,275,000</td> <td class="xl25" x:num="1500000" align="right">1,500,000</td> <td class="xl23">US</td> <td class="xl22" x:num="38387" align="right">2-4-2005</td> <td x:num="" align="right">45</td> <td>
</td> <td class="xl26" x:num="" x:fmla="=D4-D3" align="right">294.0</td> <td class="xl26">
</td> <td class="xl26">
</td> <td class="xl26">
</td> <td class="xl29" style="width: 54pt;" x:num="" width="72">1500000</td> <td class="xl23" x:num="">1</td> <td class="xl30" x:num="39082">12-31-2006</td> <td class="xl23" x:num="">5</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl25" style="height: 12.75pt;" x:num="279000" align="right" height="17">279,000</td> <td class="xl25" x:num="279000" align="right">279,000</td> <td class="xl23">CI</td> <td class="xl22" x:num="38596" align="right">9-1-2005</td> <td x:num="" align="right">436</td> <td>
</td> <td class="xl26" x:num="" x:fmla="=D5-D4" align="right">209.0</td> <td class="xl26">
</td> <td class="xl26">
</td> <td class="xl26">
</td> <td class="xl24" style="width: 54pt;" x:num="" width="72">2000000</td> <td class="xl23" x:num="">1</td> <td class="xl30" x:num="39447">12-31-2007</td> <td class="xl23" x:num="">12</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl25" style="height: 12.75pt;" x:num="3050000" align="right" height="17">3,050,000</td> <td class="xl25" x:num="3400000" align="right">3,400,000</td> <td class="xl23">US</td> <td class="xl22" x:num="38885" align="right">6-17-2006</td> <td x:num="" align="right">379</td> <td>
</td> <td class="xl26" x:num="" x:fmla="=D6-D5" align="right">289.0</td> <td class="xl26">
</td> <td class="xl26">
</td> <td class="xl26">
</td> <td class="xl24" style="width: 54pt;" x:num="2500000" width="72">2500000</td> <td class="xl23" x:num="">4</td> <td class="xl30" x:num="39813">12-31-2008</td> <td class="xl23" x:num="">3</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl25" style="height: 12.75pt;" x:num="5900000" align="right" height="17">5,900,000</td> <td class="xl25" x:num="5950000" align="right">5,950,000</td> <td class="xl23">US</td> <td class="xl22" x:num="38954" align="right">8-25-2006</td> <td x:num="" align="right">351</td> <td>
</td> <td class="xl26" x:num="" x:fmla="=D7-D6" align="right">69.0</td> <td class="xl26">
</td> <td class="xl26">
</td> <td class="xl26">
</td> <td class="xl24" style="width: 54pt;" x:num="3000000" width="72">3000000</td> <td class="xl23" x:num="">2</td> <td class="xl30" x:num="40178">12-31-2009</td> <td class="xl23" x:num="">0</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl25" style="height: 12.75pt;" x:num="5500000" align="right" height="17">5,500,000</td> <td class="xl25" x:num="5950000" align="right">5,950,000</td> <td class="xl23">US</td> <td class="xl22" x:num="38958" align="right">8-29-2006</td> <td x:num="" align="right">1859</td> <td>
</td> <td class="xl26" x:num="" x:fmla="=D8-D7" align="right">4.0</td> <td class="xl26">
</td> <td class="xl26">
</td> <td class="xl26">
</td> <td class="xl24" style="width: 54pt;" x:num="3500000" width="72">3500000</td> <td class="xl23" x:num="">1</td> <td>
</td> <td class="xl23" x:num="">0</td> </tr> </tbody></table>
What I'm trying to do is figure out how to write a macro which will give me an average DOM on a yearly basis and populate a different column with the results. I see the basic programming structure as:
1) Select cells based on date in TD column, e.g. all dates in 2004 calendar year.
2) Select those adjacent DOM cells.
3) Calculate the average DOM.
4) Post results to another column.
5) Select cells based on date in TD column + one year
6) Process repeats to end of database
I'm using Excel 03 on a Win XP box with SP3.
I hope this isn't confusing and any help would be greatly appreciated! Many thanks in advance, guys.
Kind regards,
Anthony
<input id="gwProxy" type="hidden"><!--Session data--><input *******="jsCall();" id="jsProxy" type="hidden"><input id="gwProxy" type="hidden"><!--Session data--><input *******="jsCall();" id="jsProxy" type="hidden"><input id="gwProxy" type="hidden"><!--Session data--><input *******="jsCall();" id="jsProxy" type="hidden">
I have a large real estate database with a column for Transaction Date (TD) and a column directly adjacent which shows Days on Market (DOM). The TD column is already in chronological order.
For the avoidance of doubt, the portion of the database in question looks like this:
<table x:str="" style="border-collapse: collapse; width: 622pt;" border="0" cellpadding="0" cellspacing="0" width="828"><col style="width: 72pt;" span="2" width="96"> <col style="width: 26pt;" width="34"> <col style="width: 67pt;" width="89"> <col style="width: 48pt;" width="64"> <col style="width: 16pt;" width="21"> <col style="width: 48pt;" width="64"> <col style="width: 16pt;" width="21"> <col style="width: 48pt;" span="2" width="64"> <col style="width: 18pt;" width="24"> <col style="width: 54pt;" width="72"> <col style="width: 18pt;" width="24"> <col style="width: 53pt;" width="71"> <col style="width: 18pt;" width="24"> <tbody><tr style="height: 51pt;" height="68"> <td class="xl23" style="height: 51pt; width: 72pt;" height="68" width="96">SALES PRICE</td> <td class="xl23" style="width: 72pt;" width="96">LIST PRICE</td> <td class="xl23" style="width: 26pt;" width="34">CURR.</td> <td class="xl23" style="width: 67pt;" width="89">DATE SOLD</td> <td class="xl23" style="width: 48pt;" width="64">D.O.M.</td> <td class="xl24" style="width: 16pt;" width="21">
</td> <td class="xl24" style="width: 48pt;" width="64">Days between last sale</td> <td class="xl24" style="width: 16pt;" width="21">
</td> <td class="xl24" style="width: 48pt;" width="64">Avg. DOM by year</td> <td class="xl24" style="width: 18pt;" width="24">
</td> <td class="xl24" style="width: 54pt;" width="72">Sales Freq.per SP Range</td> <td class="xl24" style="width: 18pt;" width="24">
</td> <td class="xl24" style="width: 53pt;" width="71">Qty. of Sales 010104-310109</td> <td class="xl24" style="width: 18pt;" width="24">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl25" style="height: 12.75pt;" x:num="4800000" align="right" height="17">4,800,000</td> <td class="xl25" x:num="5975000" align="right">5,975,000</td> <td class="xl23">US</td> <td class="xl31" x:num="38016" align="right">1-30-2004</td> <td x:num="" align="right">134</td> <td>
</td> <td class="xl27">
</td> <td class="xl26">
</td> <td class="xl26">
</td> <td class="xl26">
</td> <td class="xl28" x:num="">500000</td> <td class="xl23" x:num="">7</td> <td class="xl30" x:num="38352">12-31-2004</td> <td class="xl23" x:num="">2</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl25" style="height: 12.75pt;" x:num="303000" align="right" height="17">303,000</td> <td class="xl25" x:num="310000" align="right">310,000</td> <td class="xl23">CI</td> <td class="xl31" x:num="38093" align="right">4-16-2004</td> <td x:num="" align="right">129</td> <td>
</td> <td class="xl26" x:num="" x:fmla="=D3-D2" align="right">77.0</td> <td class="xl26">
</td> <td class="xl26">
</td> <td class="xl26">
</td> <td class="xl29" style="width: 54pt;" x:num="" width="72">1000000</td> <td class="xl23" x:num="">3</td> <td class="xl30" x:num="38717">12-31-2005</td> <td class="xl23" x:num="">2</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl25" style="height: 12.75pt;" x:num="1275000" align="right" height="17">1,275,000</td> <td class="xl25" x:num="1500000" align="right">1,500,000</td> <td class="xl23">US</td> <td class="xl22" x:num="38387" align="right">2-4-2005</td> <td x:num="" align="right">45</td> <td>
</td> <td class="xl26" x:num="" x:fmla="=D4-D3" align="right">294.0</td> <td class="xl26">
</td> <td class="xl26">
</td> <td class="xl26">
</td> <td class="xl29" style="width: 54pt;" x:num="" width="72">1500000</td> <td class="xl23" x:num="">1</td> <td class="xl30" x:num="39082">12-31-2006</td> <td class="xl23" x:num="">5</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl25" style="height: 12.75pt;" x:num="279000" align="right" height="17">279,000</td> <td class="xl25" x:num="279000" align="right">279,000</td> <td class="xl23">CI</td> <td class="xl22" x:num="38596" align="right">9-1-2005</td> <td x:num="" align="right">436</td> <td>
</td> <td class="xl26" x:num="" x:fmla="=D5-D4" align="right">209.0</td> <td class="xl26">
</td> <td class="xl26">
</td> <td class="xl26">
</td> <td class="xl24" style="width: 54pt;" x:num="" width="72">2000000</td> <td class="xl23" x:num="">1</td> <td class="xl30" x:num="39447">12-31-2007</td> <td class="xl23" x:num="">12</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl25" style="height: 12.75pt;" x:num="3050000" align="right" height="17">3,050,000</td> <td class="xl25" x:num="3400000" align="right">3,400,000</td> <td class="xl23">US</td> <td class="xl22" x:num="38885" align="right">6-17-2006</td> <td x:num="" align="right">379</td> <td>
</td> <td class="xl26" x:num="" x:fmla="=D6-D5" align="right">289.0</td> <td class="xl26">
</td> <td class="xl26">
</td> <td class="xl26">
</td> <td class="xl24" style="width: 54pt;" x:num="2500000" width="72">2500000</td> <td class="xl23" x:num="">4</td> <td class="xl30" x:num="39813">12-31-2008</td> <td class="xl23" x:num="">3</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl25" style="height: 12.75pt;" x:num="5900000" align="right" height="17">5,900,000</td> <td class="xl25" x:num="5950000" align="right">5,950,000</td> <td class="xl23">US</td> <td class="xl22" x:num="38954" align="right">8-25-2006</td> <td x:num="" align="right">351</td> <td>
</td> <td class="xl26" x:num="" x:fmla="=D7-D6" align="right">69.0</td> <td class="xl26">
</td> <td class="xl26">
</td> <td class="xl26">
</td> <td class="xl24" style="width: 54pt;" x:num="3000000" width="72">3000000</td> <td class="xl23" x:num="">2</td> <td class="xl30" x:num="40178">12-31-2009</td> <td class="xl23" x:num="">0</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl25" style="height: 12.75pt;" x:num="5500000" align="right" height="17">5,500,000</td> <td class="xl25" x:num="5950000" align="right">5,950,000</td> <td class="xl23">US</td> <td class="xl22" x:num="38958" align="right">8-29-2006</td> <td x:num="" align="right">1859</td> <td>
</td> <td class="xl26" x:num="" x:fmla="=D8-D7" align="right">4.0</td> <td class="xl26">
</td> <td class="xl26">
</td> <td class="xl26">
</td> <td class="xl24" style="width: 54pt;" x:num="3500000" width="72">3500000</td> <td class="xl23" x:num="">1</td> <td>
</td> <td class="xl23" x:num="">0</td> </tr> </tbody></table>
What I'm trying to do is figure out how to write a macro which will give me an average DOM on a yearly basis and populate a different column with the results. I see the basic programming structure as:
1) Select cells based on date in TD column, e.g. all dates in 2004 calendar year.
2) Select those adjacent DOM cells.
3) Calculate the average DOM.
4) Post results to another column.
5) Select cells based on date in TD column + one year
6) Process repeats to end of database
I'm using Excel 03 on a Win XP box with SP3.
I hope this isn't confusing and any help would be greatly appreciated! Many thanks in advance, guys.
Kind regards,
Anthony
<input id="gwProxy" type="hidden"><!--Session data--><input *******="jsCall();" id="jsProxy" type="hidden"><input id="gwProxy" type="hidden"><!--Session data--><input *******="jsCall();" id="jsProxy" type="hidden"><input id="gwProxy" type="hidden"><!--Session data--><input *******="jsCall();" id="jsProxy" type="hidden">