TalkieToaster
New Member
- Joined
- Jun 3, 2012
- Messages
- 7
Hi guys,
I have what is in my mind a rather complex problem, but which is probably childsplay to you Excel boffins
I've been playing around with this for a while and can't determine the best way to approach it.
In short, I have two columns of data produced by an external application; Age and Postcode. The raw data looks like this:
Excel 2010<table rules="all" style=";background-color: #FFFFFF;border: 1px solid;border-collapse: collapse; border-color: #BBB" cellpadding="2.5px"><colgroup><col style="background-color: #DAE7F5" width="25px"><col><col></colgroup><thead><tr style=" background-color: #DAE7F5;text-align: center;color: #161120"><th>
</th><th>E</th><th>F</th></tr></thead><tbody><tr><td style="color: #161120;text-align: center;">14</td><td style="font-weight: bold;;">Age</td><td style="font-weight: bold;;">Post Code</td></tr><tr><td style="color: #161120;text-align: center;">15</td><td style="text-align: right;;">29</td><td style=";">AB1 2GQ</td></tr><tr><td style="color: #161120;text-align: center;">16</td><td style="text-align: right;;">43</td><td style=";">AB1 3EZ</td></tr><tr><td style="color: #161120;text-align: center;">17</td><td style="text-align: right;;">41</td><td style=";">AB10 0DN</td></tr><tr><td style="color: #161120;text-align: center;">18</td><td style="text-align: right;;">20</td><td style=";">AB11 9PL</td></tr><tr><td style="color: #161120;text-align: center;">19</td><td style="text-align: right;;">54</td><td style=";">AB13 2RG</td></tr><tr><td style="color: #161120;text-align: center;">20</td><td style="text-align: right;;">21</td><td style=";">AB14 7EH</td></tr><tr><td style="color: #161120;text-align: center;">21</td><td style="text-align: right;;">59</td><td style=";">AB19 7HG</td></tr><tr><td style="color: #161120;text-align: center;">22</td><td style="text-align: right;;">32</td><td style=";">AB2 7AG</td></tr><tr><td style="color: #161120;text-align: center;">23</td><td style="text-align: right;;">21</td><td style=";">AB20 3AZ</td></tr><tr><td style="color: #161120;text-align: center;">24</td><td style="text-align: right;;">47</td><td style=";">AB9 7EE</td></tr><tr><td style="color: #161120;text-align: center;">25</td><td style="text-align: right;;">29</td><td style=";">X72 7RD</td></tr><tr><td style="color: #161120;text-align: center;">26</td><td style="text-align: right;;">25</td><td style=";">U/K</td></tr><tr><td style="color: #161120;text-align: center;">27</td><td style="text-align: right;;">51</td><td style=";">AB28 2JP</td></tr><tr><td style="color: #161120;text-align: center;">28</td><td style="text-align: right;;">20</td><td style=";">AB30 6UB</td></tr><tr><td style="color: #161120;text-align: center;">29</td><td style="text-align: right;;">50</td><td style=";">AB4 1BP</td></tr><tr><td style="color: #161120;text-align: center;">30</td><td style="text-align: right;;">26</td><td style=";">AB5 4HQ</td></tr></tbody></table>
That's only an example, the actual data is about 200 rows usually. As you can see, the ages and postcodes are in no particular order. What I need to do, is sort it so the postcodes are in ascending numerical order according to the numbers after the initial AB (the last three digits of the postcode are irrelevant and can be ignored), then sort the ages in ascending order grouped by the postcodes.
The end result of all this is I need to produce a table which shows a count of how many people in each particular age ranges reside in a particular district (which is a grouping of postcodes). The age ranges are: 18-19, 20-29, 30-39, 40-49, 50-59, 60+.
The postcodes are grouped into 8 districts as follows:
District 1: AB14, AB15, AB36
District 2: AB11, AB12, AB13, AB17
District 3: AB1, AB7, AB8, AB9, AB10
District 4: AB4, AB5, AB6, AB16
District 5: AB27, AB28, AB66, AB67
District 6: AB24, AB30, AB31, AB33
District 7: AB19, AB20, AB22, AB23
District 8 (OTHER): Any postcode which doesn't start AB (for example cells 25 and 26 above)
I know this sounds convoluted, but the end results simply look like this:
Excel 2010<table rules="all" style=";background-color: #FFFFFF;border: 1px solid;border-collapse: collapse; border-color: #BBB" cellpadding="2.5px"><colgroup><col style="background-color: #DAE7F5" width="25px"><col><col><col><col><col><col><col></colgroup><thead><tr style=" background-color: #DAE7F5;text-align: center;color: #161120"><th>
</th><th>D</th><th>E</th><th>F</th><th>G</th><th>H</th><th>I</th><th>J</th></tr></thead><tbody><tr><td style="color: #161120;text-align: center;">1</td><td style="text-align: right;;">
</td><td style="font-weight: bold;background-color: #B8CCE4;;">18-19</td><td style="font-weight: bold;background-color: #B8CCE4;;">20-29</td><td style="font-weight: bold;background-color: #B8CCE4;;">30-39</td><td style="font-weight: bold;background-color: #B8CCE4;;">40-49</td><td style="font-weight: bold;background-color: #B8CCE4;;">50-59</td><td style="font-weight: bold;text-align: right;background-color: #B8CCE4;;">60+</td></tr><tr><td style="color: #161120;text-align: center;">2</td><td style="font-weight: bold;background-color: #F2DCDB;;">District 1</td><td style="text-align: right;;">0</td><td style="text-align: right;;">12</td><td style="text-align: right;;">9</td><td style="text-align: right;;">8</td><td style="text-align: right;;">4</td><td style="text-align: right;;">1</td></tr><tr><td style="color: #161120;text-align: center;">3</td><td style="font-weight: bold;background-color: #F2DCDB;;">District 2</td><td style="text-align: right;;">0</td><td style="text-align: right;;">8</td><td style="text-align: right;;">5</td><td style="text-align: right;;">7</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td></tr><tr><td style="color: #161120;text-align: center;">4</td><td style="font-weight: bold;background-color: #F2DCDB;;">District 3</td><td style="text-align: right;;">0</td><td style="text-align: right;;">7</td><td style="text-align: right;;">6</td><td style="text-align: right;;">9</td><td style="text-align: right;;">3</td><td style="text-align: right;;">0</td></tr><tr><td style="color: #161120;text-align: center;">5</td><td style="font-weight: bold;background-color: #F2DCDB;;">District 4</td><td style="text-align: right;;">2</td><td style="text-align: right;;">17</td><td style="text-align: right;;">19</td><td style="text-align: right;;">16</td><td style="text-align: right;;">3</td><td style="text-align: right;;">0</td></tr><tr><td style="color: #161120;text-align: center;">6</td><td style="font-weight: bold;background-color: #F2DCDB;;">District 5</td><td style="text-align: right;;">0</td><td style="text-align: right;;">4</td><td style="text-align: right;;">6</td><td style="text-align: right;;">7</td><td style="text-align: right;;">2</td><td style="text-align: right;;">0</td></tr><tr><td style="color: #161120;text-align: center;">7</td><td style="font-weight: bold;background-color: #F2DCDB;;">District 6</td><td style="text-align: right;;">1</td><td style="text-align: right;;">9</td><td style="text-align: right;;">3</td><td style="text-align: right;;">4</td><td style="text-align: right;;">2</td><td style="text-align: right;;">0</td></tr><tr><td style="color: #161120;text-align: center;">8</td><td style="font-weight: bold;background-color: #F2DCDB;;">District 7</td><td style="text-align: right;;">0</td><td style="text-align: right;;">9</td><td style="text-align: right;;">7</td><td style="text-align: right;;">4</td><td style="text-align: right;;">2</td><td style="text-align: right;;">0</td></tr><tr><td style="color: #161120;text-align: center;">9</td><td style="font-weight: bold;background-color: #F2DCDB;;">District 8 OTHER</td><td style="text-align: right;;">0</td><td style="text-align: right;;">2</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td></tr></tbody></table>
I hope that makes sense.
I know this is probably a fairly simple process to do with a formula or even a small bit of VBA, but I'm not sure how to approach it. I looked at this thread and can sort the postcodes into ascending order by splitting off the 'AB' as described, but sorting them may not even be necessary if there was some COUNT formula I could use which was capable of counting the occurance of each age range and incrementing the number of that range in a particular postcode district.
Sorry if the above sounds vague, I hope the data samples help make more sense of it.
I'm not too bad with Excel but I would really appreciate any thoughts on how to approach this particular problem from some of you guys, you'll probably laugh at how simple it is, but I just can't see it!
I'm very grateful for any pointers
I have what is in my mind a rather complex problem, but which is probably childsplay to you Excel boffins
I've been playing around with this for a while and can't determine the best way to approach it.
In short, I have two columns of data produced by an external application; Age and Postcode. The raw data looks like this:
Excel 2010<table rules="all" style=";background-color: #FFFFFF;border: 1px solid;border-collapse: collapse; border-color: #BBB" cellpadding="2.5px"><colgroup><col style="background-color: #DAE7F5" width="25px"><col><col></colgroup><thead><tr style=" background-color: #DAE7F5;text-align: center;color: #161120"><th>
</th><th>E</th><th>F</th></tr></thead><tbody><tr><td style="color: #161120;text-align: center;">14</td><td style="font-weight: bold;;">Age</td><td style="font-weight: bold;;">Post Code</td></tr><tr><td style="color: #161120;text-align: center;">15</td><td style="text-align: right;;">29</td><td style=";">AB1 2GQ</td></tr><tr><td style="color: #161120;text-align: center;">16</td><td style="text-align: right;;">43</td><td style=";">AB1 3EZ</td></tr><tr><td style="color: #161120;text-align: center;">17</td><td style="text-align: right;;">41</td><td style=";">AB10 0DN</td></tr><tr><td style="color: #161120;text-align: center;">18</td><td style="text-align: right;;">20</td><td style=";">AB11 9PL</td></tr><tr><td style="color: #161120;text-align: center;">19</td><td style="text-align: right;;">54</td><td style=";">AB13 2RG</td></tr><tr><td style="color: #161120;text-align: center;">20</td><td style="text-align: right;;">21</td><td style=";">AB14 7EH</td></tr><tr><td style="color: #161120;text-align: center;">21</td><td style="text-align: right;;">59</td><td style=";">AB19 7HG</td></tr><tr><td style="color: #161120;text-align: center;">22</td><td style="text-align: right;;">32</td><td style=";">AB2 7AG</td></tr><tr><td style="color: #161120;text-align: center;">23</td><td style="text-align: right;;">21</td><td style=";">AB20 3AZ</td></tr><tr><td style="color: #161120;text-align: center;">24</td><td style="text-align: right;;">47</td><td style=";">AB9 7EE</td></tr><tr><td style="color: #161120;text-align: center;">25</td><td style="text-align: right;;">29</td><td style=";">X72 7RD</td></tr><tr><td style="color: #161120;text-align: center;">26</td><td style="text-align: right;;">25</td><td style=";">U/K</td></tr><tr><td style="color: #161120;text-align: center;">27</td><td style="text-align: right;;">51</td><td style=";">AB28 2JP</td></tr><tr><td style="color: #161120;text-align: center;">28</td><td style="text-align: right;;">20</td><td style=";">AB30 6UB</td></tr><tr><td style="color: #161120;text-align: center;">29</td><td style="text-align: right;;">50</td><td style=";">AB4 1BP</td></tr><tr><td style="color: #161120;text-align: center;">30</td><td style="text-align: right;;">26</td><td style=";">AB5 4HQ</td></tr></tbody></table>
That's only an example, the actual data is about 200 rows usually. As you can see, the ages and postcodes are in no particular order. What I need to do, is sort it so the postcodes are in ascending numerical order according to the numbers after the initial AB (the last three digits of the postcode are irrelevant and can be ignored), then sort the ages in ascending order grouped by the postcodes.
The end result of all this is I need to produce a table which shows a count of how many people in each particular age ranges reside in a particular district (which is a grouping of postcodes). The age ranges are: 18-19, 20-29, 30-39, 40-49, 50-59, 60+.
The postcodes are grouped into 8 districts as follows:
District 1: AB14, AB15, AB36
District 2: AB11, AB12, AB13, AB17
District 3: AB1, AB7, AB8, AB9, AB10
District 4: AB4, AB5, AB6, AB16
District 5: AB27, AB28, AB66, AB67
District 6: AB24, AB30, AB31, AB33
District 7: AB19, AB20, AB22, AB23
District 8 (OTHER): Any postcode which doesn't start AB (for example cells 25 and 26 above)
I know this sounds convoluted, but the end results simply look like this:
Excel 2010<table rules="all" style=";background-color: #FFFFFF;border: 1px solid;border-collapse: collapse; border-color: #BBB" cellpadding="2.5px"><colgroup><col style="background-color: #DAE7F5" width="25px"><col><col><col><col><col><col><col></colgroup><thead><tr style=" background-color: #DAE7F5;text-align: center;color: #161120"><th>
</th><th>D</th><th>E</th><th>F</th><th>G</th><th>H</th><th>I</th><th>J</th></tr></thead><tbody><tr><td style="color: #161120;text-align: center;">1</td><td style="text-align: right;;">
</td><td style="font-weight: bold;background-color: #B8CCE4;;">18-19</td><td style="font-weight: bold;background-color: #B8CCE4;;">20-29</td><td style="font-weight: bold;background-color: #B8CCE4;;">30-39</td><td style="font-weight: bold;background-color: #B8CCE4;;">40-49</td><td style="font-weight: bold;background-color: #B8CCE4;;">50-59</td><td style="font-weight: bold;text-align: right;background-color: #B8CCE4;;">60+</td></tr><tr><td style="color: #161120;text-align: center;">2</td><td style="font-weight: bold;background-color: #F2DCDB;;">District 1</td><td style="text-align: right;;">0</td><td style="text-align: right;;">12</td><td style="text-align: right;;">9</td><td style="text-align: right;;">8</td><td style="text-align: right;;">4</td><td style="text-align: right;;">1</td></tr><tr><td style="color: #161120;text-align: center;">3</td><td style="font-weight: bold;background-color: #F2DCDB;;">District 2</td><td style="text-align: right;;">0</td><td style="text-align: right;;">8</td><td style="text-align: right;;">5</td><td style="text-align: right;;">7</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td></tr><tr><td style="color: #161120;text-align: center;">4</td><td style="font-weight: bold;background-color: #F2DCDB;;">District 3</td><td style="text-align: right;;">0</td><td style="text-align: right;;">7</td><td style="text-align: right;;">6</td><td style="text-align: right;;">9</td><td style="text-align: right;;">3</td><td style="text-align: right;;">0</td></tr><tr><td style="color: #161120;text-align: center;">5</td><td style="font-weight: bold;background-color: #F2DCDB;;">District 4</td><td style="text-align: right;;">2</td><td style="text-align: right;;">17</td><td style="text-align: right;;">19</td><td style="text-align: right;;">16</td><td style="text-align: right;;">3</td><td style="text-align: right;;">0</td></tr><tr><td style="color: #161120;text-align: center;">6</td><td style="font-weight: bold;background-color: #F2DCDB;;">District 5</td><td style="text-align: right;;">0</td><td style="text-align: right;;">4</td><td style="text-align: right;;">6</td><td style="text-align: right;;">7</td><td style="text-align: right;;">2</td><td style="text-align: right;;">0</td></tr><tr><td style="color: #161120;text-align: center;">7</td><td style="font-weight: bold;background-color: #F2DCDB;;">District 6</td><td style="text-align: right;;">1</td><td style="text-align: right;;">9</td><td style="text-align: right;;">3</td><td style="text-align: right;;">4</td><td style="text-align: right;;">2</td><td style="text-align: right;;">0</td></tr><tr><td style="color: #161120;text-align: center;">8</td><td style="font-weight: bold;background-color: #F2DCDB;;">District 7</td><td style="text-align: right;;">0</td><td style="text-align: right;;">9</td><td style="text-align: right;;">7</td><td style="text-align: right;;">4</td><td style="text-align: right;;">2</td><td style="text-align: right;;">0</td></tr><tr><td style="color: #161120;text-align: center;">9</td><td style="font-weight: bold;background-color: #F2DCDB;;">District 8 OTHER</td><td style="text-align: right;;">0</td><td style="text-align: right;;">2</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td><td style="text-align: right;;">0</td></tr></tbody></table>
I hope that makes sense.
I know this is probably a fairly simple process to do with a formula or even a small bit of VBA, but I'm not sure how to approach it. I looked at this thread and can sort the postcodes into ascending order by splitting off the 'AB' as described, but sorting them may not even be necessary if there was some COUNT formula I could use which was capable of counting the occurance of each age range and incrementing the number of that range in a particular postcode district.
Sorry if the above sounds vague, I hope the data samples help make more sense of it.
I'm not too bad with Excel but I would really appreciate any thoughts on how to approach this particular problem from some of you guys, you'll probably laugh at how simple it is, but I just can't see it!
I'm very grateful for any pointers
Last edited: