VoG
Legend
- Joined
- Jun 19, 2002
- Messages
- 63,650
Hello. I have a problem that I believe is soluble using VBA but I would really prefer a formula approach. This is an example of my sheet with several columns removed for clarity.
<b>Z207</b><br /><br /><table border="1" cellspacing="0" cellpadding="0" style="font-family:Arial,Arial; font-size:10pt; background-color:#ffffff; padding-left:2pt; padding-right:2pt; "> <colgroup><col style="font-weight:bold; width:30px; " /><col style="width:64px;" /><col style="width:59px;" /><col style="width:64px;" /><col style="width:78px;" /><col style="width:64px;" /><col style="width:42px;" /><col style="width:64px;" /><col style="width:64px;" /></colgroup><tr style="background-color:#cacaca; text-align:center; font-weight:bold; font-size:8pt; "><td > </td><td >A</td><td >B</td><td >C</td><td >D</td><td >E</td><td >F</td><td >G</td><td >H</td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >1</td><td >Result</td><td >Easting</td><td >Northing</td><td >SampleDate</td><td >Dist (m)</td><td > </td><td > </td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >2</td><td style="text-align:right; ">49.63</td><td style="text-align:right; ">359265</td><td style="text-align:right; ">181460</td><td style="text-align:right; ">10/05/2004</td><td style="text-align:right; ">694</td><td > </td><td style="text-align:right; ">2004</td><td style="text-align:right; ">123</td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >3</td><td style="text-align:right; ">94.68</td><td style="text-align:right; ">361223</td><td style="text-align:right; ">182613</td><td style="text-align:right; ">24/06/2004</td><td style="text-align:right; ">1579</td><td > </td><td style="text-align:right; ">2005</td><td style="text-align:right; ">33</td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >4</td><td style="background-color:#ff0000; text-align:right; ">123</td><td style="text-align:right; ">359850</td><td style="text-align:right; ">181834</td><td style="text-align:right; ">02/08/2004</td><td style="text-align:right; ">0</td><td > </td><td style="text-align:right; ">2006</td><td style="text-align:right; ">80.15</td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >5</td><td style="text-align:right; ">66.1</td><td style="text-align:right; ">360362</td><td style="text-align:right; ">181769</td><td style="text-align:right; ">26/10/2004</td><td style="text-align:right; ">516</td><td > </td><td style="text-align:right; ">2007</td><td style="text-align:right; ">67.3</td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >6</td><td style="text-align:right; ">35.98</td><td style="text-align:right; ">363199</td><td style="text-align:right; ">180609</td><td style="text-align:right; ">29/11/2004</td><td style="text-align:right; ">3566</td><td > </td><td > </td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >7</td><td style="text-align:right; ">27.31</td><td style="text-align:right; ">362832</td><td style="text-align:right; ">180672</td><td style="text-align:right; ">23/02/2005</td><td style="text-align:right; ">3200</td><td > </td><td > </td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >8</td><td style="text-align:right; ">33</td><td style="text-align:right; ">359355</td><td style="text-align:right; ">181969</td><td style="text-align:right; ">11/04/2005</td><td style="text-align:right; ">513</td><td > </td><td > </td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >9</td><td style="text-align:right; ">31.11</td><td style="text-align:right; ">362593</td><td style="text-align:right; ">180297</td><td style="text-align:right; ">25/05/2005</td><td style="text-align:right; ">3144</td><td > </td><td > </td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >10</td><td style="text-align:right; ">81.2</td><td style="text-align:right; ">361525</td><td style="text-align:right; ">183027</td><td style="text-align:right; ">06/10/2005</td><td style="text-align:right; ">2056</td><td > </td><td > </td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >11</td><td style="text-align:right; ">42.48</td><td style="text-align:right; ">361588</td><td style="text-align:right; ">181688</td><td style="text-align:right; ">15/11/2005</td><td style="text-align:right; ">1744</td><td > </td><td > </td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >12</td><td style="text-align:right; ">20.92</td><td style="text-align:right; ">362252</td><td style="text-align:right; ">180143</td><td style="text-align:right; ">31/01/2006</td><td style="text-align:right; ">2938</td><td > </td><td > </td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >13</td><td style="text-align:right; ">48.55</td><td style="text-align:right; ">361353</td><td style="text-align:right; ">181673</td><td style="text-align:right; ">27/07/2006</td><td style="text-align:right; ">1512</td><td > </td><td > </td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >14</td><td style="text-align:right; ">139.6</td><td style="text-align:right; ">363038</td><td style="text-align:right; ">180926</td><td style="text-align:right; ">13/09/2006</td><td style="text-align:right; ">3315</td><td > </td><td > </td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >15</td><td style="text-align:right; ">80.15</td><td style="text-align:right; ">360326</td><td style="text-align:right; ">181898</td><td style="text-align:right; ">03/11/2006</td><td style="text-align:right; ">480</td><td > </td><td > </td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >16</td><td style="text-align:right; ">32.93</td><td style="text-align:right; ">360802</td><td style="text-align:right; ">181710</td><td style="text-align:right; ">11/12/2006</td><td style="text-align:right; ">960</td><td > </td><td > </td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >17</td><td style="text-align:right; ">23</td><td style="text-align:right; ">362232</td><td style="text-align:right; ">181339</td><td style="text-align:right; ">25/01/2007</td><td style="text-align:right; ">2433</td><td > </td><td > </td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >18</td><td style="text-align:right; ">22.6</td><td style="text-align:right; ">365264</td><td style="text-align:right; ">181066</td><td style="text-align:right; ">06/03/2007</td><td style="text-align:right; ">5468</td><td > </td><td > </td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >19</td><td style="text-align:right; ">39.7</td><td style="text-align:right; ">362376</td><td style="text-align:right; ">180837</td><td style="text-align:right; ">25/04/2007</td><td style="text-align:right; ">2716</td><td > </td><td > </td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >20</td><td style="text-align:right; ">67.3</td><td style="text-align:right; ">359849</td><td style="text-align:right; ">181418</td><td style="text-align:right; ">07/06/2007</td><td style="text-align:right; ">416</td><td > </td><td > </td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >21</td><td style="text-align:right; ">22.6</td><td style="text-align:right; ">361283</td><td style="text-align:right; ">181706</td><td style="text-align:right; ">14/12/2007</td><td style="text-align:right; ">1439</td><td > </td><td > </td><td > </td></tr></table><br /><table style="font-family:Arial; font-size:10pt; border-style: groove ;border-color:#00ff00;background-color:#fffcf9; color:#000000; "><tr><td ><b>Spreadsheet Formulas</b></td></tr><tr><td ><table border = "1" cellspacing="0" cellpadding="2" style="font-family:Arial; font-size:9pt;"><tr style="background-color:#cacaca; font-size:10pt;"><td >Cell</td><td >Formula</td></tr><tr><td >E2</td><td >=SQRT(<span style=' color:008000; '>(B2-B$4)</span>^2+<span style=' color:008000; '>(C2-C$4)</span>^2)</td></tr></table></td></tr></table> <br />Excel tables to the web - Excel Jeanie Html 4
What I have done here manually is as follows.
1) Identified the highest result (column A) occurring in 2004.
2) Calculated the distance between each sample point (formulas in column E) and the point identified in 1)
3) For each year 2005, 2006, 2007 found the result in column A corresponding to the closest point (i.e. smallest distance) compared to the sample identified in 1)
4) Filled in the matching values in columns G and H.
Is this even possible using a formula
I've done half a dozen of these by hand but I think that my client may want many (hundreds ) more.
Thanks in advance.
<b>Z207</b><br /><br /><table border="1" cellspacing="0" cellpadding="0" style="font-family:Arial,Arial; font-size:10pt; background-color:#ffffff; padding-left:2pt; padding-right:2pt; "> <colgroup><col style="font-weight:bold; width:30px; " /><col style="width:64px;" /><col style="width:59px;" /><col style="width:64px;" /><col style="width:78px;" /><col style="width:64px;" /><col style="width:42px;" /><col style="width:64px;" /><col style="width:64px;" /></colgroup><tr style="background-color:#cacaca; text-align:center; font-weight:bold; font-size:8pt; "><td > </td><td >A</td><td >B</td><td >C</td><td >D</td><td >E</td><td >F</td><td >G</td><td >H</td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >1</td><td >Result</td><td >Easting</td><td >Northing</td><td >SampleDate</td><td >Dist (m)</td><td > </td><td > </td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >2</td><td style="text-align:right; ">49.63</td><td style="text-align:right; ">359265</td><td style="text-align:right; ">181460</td><td style="text-align:right; ">10/05/2004</td><td style="text-align:right; ">694</td><td > </td><td style="text-align:right; ">2004</td><td style="text-align:right; ">123</td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >3</td><td style="text-align:right; ">94.68</td><td style="text-align:right; ">361223</td><td style="text-align:right; ">182613</td><td style="text-align:right; ">24/06/2004</td><td style="text-align:right; ">1579</td><td > </td><td style="text-align:right; ">2005</td><td style="text-align:right; ">33</td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >4</td><td style="background-color:#ff0000; text-align:right; ">123</td><td style="text-align:right; ">359850</td><td style="text-align:right; ">181834</td><td style="text-align:right; ">02/08/2004</td><td style="text-align:right; ">0</td><td > </td><td style="text-align:right; ">2006</td><td style="text-align:right; ">80.15</td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >5</td><td style="text-align:right; ">66.1</td><td style="text-align:right; ">360362</td><td style="text-align:right; ">181769</td><td style="text-align:right; ">26/10/2004</td><td style="text-align:right; ">516</td><td > </td><td style="text-align:right; ">2007</td><td style="text-align:right; ">67.3</td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >6</td><td style="text-align:right; ">35.98</td><td style="text-align:right; ">363199</td><td style="text-align:right; ">180609</td><td style="text-align:right; ">29/11/2004</td><td style="text-align:right; ">3566</td><td > </td><td > </td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >7</td><td style="text-align:right; ">27.31</td><td style="text-align:right; ">362832</td><td style="text-align:right; ">180672</td><td style="text-align:right; ">23/02/2005</td><td style="text-align:right; ">3200</td><td > </td><td > </td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >8</td><td style="text-align:right; ">33</td><td style="text-align:right; ">359355</td><td style="text-align:right; ">181969</td><td style="text-align:right; ">11/04/2005</td><td style="text-align:right; ">513</td><td > </td><td > </td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >9</td><td style="text-align:right; ">31.11</td><td style="text-align:right; ">362593</td><td style="text-align:right; ">180297</td><td style="text-align:right; ">25/05/2005</td><td style="text-align:right; ">3144</td><td > </td><td > </td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >10</td><td style="text-align:right; ">81.2</td><td style="text-align:right; ">361525</td><td style="text-align:right; ">183027</td><td style="text-align:right; ">06/10/2005</td><td style="text-align:right; ">2056</td><td > </td><td > </td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >11</td><td style="text-align:right; ">42.48</td><td style="text-align:right; ">361588</td><td style="text-align:right; ">181688</td><td style="text-align:right; ">15/11/2005</td><td style="text-align:right; ">1744</td><td > </td><td > </td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >12</td><td style="text-align:right; ">20.92</td><td style="text-align:right; ">362252</td><td style="text-align:right; ">180143</td><td style="text-align:right; ">31/01/2006</td><td style="text-align:right; ">2938</td><td > </td><td > </td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >13</td><td style="text-align:right; ">48.55</td><td style="text-align:right; ">361353</td><td style="text-align:right; ">181673</td><td style="text-align:right; ">27/07/2006</td><td style="text-align:right; ">1512</td><td > </td><td > </td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >14</td><td style="text-align:right; ">139.6</td><td style="text-align:right; ">363038</td><td style="text-align:right; ">180926</td><td style="text-align:right; ">13/09/2006</td><td style="text-align:right; ">3315</td><td > </td><td > </td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >15</td><td style="text-align:right; ">80.15</td><td style="text-align:right; ">360326</td><td style="text-align:right; ">181898</td><td style="text-align:right; ">03/11/2006</td><td style="text-align:right; ">480</td><td > </td><td > </td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >16</td><td style="text-align:right; ">32.93</td><td style="text-align:right; ">360802</td><td style="text-align:right; ">181710</td><td style="text-align:right; ">11/12/2006</td><td style="text-align:right; ">960</td><td > </td><td > </td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >17</td><td style="text-align:right; ">23</td><td style="text-align:right; ">362232</td><td style="text-align:right; ">181339</td><td style="text-align:right; ">25/01/2007</td><td style="text-align:right; ">2433</td><td > </td><td > </td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >18</td><td style="text-align:right; ">22.6</td><td style="text-align:right; ">365264</td><td style="text-align:right; ">181066</td><td style="text-align:right; ">06/03/2007</td><td style="text-align:right; ">5468</td><td > </td><td > </td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >19</td><td style="text-align:right; ">39.7</td><td style="text-align:right; ">362376</td><td style="text-align:right; ">180837</td><td style="text-align:right; ">25/04/2007</td><td style="text-align:right; ">2716</td><td > </td><td > </td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >20</td><td style="text-align:right; ">67.3</td><td style="text-align:right; ">359849</td><td style="text-align:right; ">181418</td><td style="text-align:right; ">07/06/2007</td><td style="text-align:right; ">416</td><td > </td><td > </td><td > </td></tr><tr style="height:17px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >21</td><td style="text-align:right; ">22.6</td><td style="text-align:right; ">361283</td><td style="text-align:right; ">181706</td><td style="text-align:right; ">14/12/2007</td><td style="text-align:right; ">1439</td><td > </td><td > </td><td > </td></tr></table><br /><table style="font-family:Arial; font-size:10pt; border-style: groove ;border-color:#00ff00;background-color:#fffcf9; color:#000000; "><tr><td ><b>Spreadsheet Formulas</b></td></tr><tr><td ><table border = "1" cellspacing="0" cellpadding="2" style="font-family:Arial; font-size:9pt;"><tr style="background-color:#cacaca; font-size:10pt;"><td >Cell</td><td >Formula</td></tr><tr><td >E2</td><td >=SQRT(<span style=' color:008000; '>(B2-B$4)</span>^2+<span style=' color:008000; '>(C2-C$4)</span>^2)</td></tr></table></td></tr></table> <br />Excel tables to the web - Excel Jeanie Html 4
What I have done here manually is as follows.
1) Identified the highest result (column A) occurring in 2004.
2) Calculated the distance between each sample point (formulas in column E) and the point identified in 1)
3) For each year 2005, 2006, 2007 found the result in column A corresponding to the closest point (i.e. smallest distance) compared to the sample identified in 1)
4) Filled in the matching values in columns G and H.
Is this even possible using a formula
I've done half a dozen of these by hand but I think that my client may want many (hundreds ) more.
Thanks in advance.