subtotaling a range based on cells

dinotom

Active Member
Joined
Aug 2, 2009
Messages
357
so I have a sheet with hundreds of customers, whose distributor name follows the customer name in the same cell. Using >Find, i can locate each distributors cells. How can I total the columns for certain distributors? You can't use Instr function in the worksheet and Im trying to figure out if i can do it all in code with out using Union to grab the range of all the distributors rows, copying them to a temporary sheet and then totaling each column.
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
If I understand correctly what you want, then this can help you:

<b>Excel 2007</b><table cellpadding="2.5px" rules="all" style=";background-color: #FFFFFF;border: 1px solid;border-collapse: collapse; border-color: #A6AAB6"><colgroup><col width="25px" style="background-color: #E0E0F0" /><col /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: #E0E0F0;text-align: center;color: #161120"><th></th><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th></tr></thead><tbody><tr ><td style="color: #161120;text-align: center;">1</td><td style="font-weight: bold;;">Col01</td><td style="font-weight: bold;;">Col02</td><td style="font-weight: bold;text-align: right;;"></td><td style="font-weight: bold;;">Distribuitor</td><td style="font-weight: bold;;">Result</td></tr><tr ><td style="color: #161120;text-align: center;">2</td><td style=";">Customer13 Distribuitor19</td><td style="text-align: right;;">617</td><td style="text-align: right;;"></td><td style=";">Distribuitor11</td><td style="text-align: right;;">276</td></tr><tr ><td style="color: #161120;text-align: center;">3</td><td style=";">Customer15 Distribuitor15</td><td style="text-align: right;;">105</td><td style="text-align: right;;"></td><td style=";">Distribuitor12</td><td style="text-align: right;;">1,990</td></tr><tr ><td style="color: #161120;text-align: center;">4</td><td style=";">Customer20 Distribuitor13</td><td style="text-align: right;;">338</td><td style="text-align: right;;"></td><td style=";">Distribuitor13</td><td style="text-align: right;;">1,841</td></tr><tr ><td style="color: #161120;text-align: center;">5</td><td style=";">Customer19 Distribuitor12</td><td style="text-align: right;;">298</td><td style="text-align: right;;"></td><td style=";">Distribuitor14</td><td style="text-align: right;;">545</td></tr><tr ><td style="color: #161120;text-align: center;">6</td><td style=";">Customer11 Distribuitor19</td><td style="text-align: right;;">185</td><td style="text-align: right;;"></td><td style=";">Distribuitor15</td><td style="text-align: right;;">1,537</td></tr><tr ><td style="color: #161120;text-align: center;">7</td><td style=";">Customer16 Distribuitor19</td><td style="text-align: right;;">420</td><td style="text-align: right;;"></td><td style=";">Distribuitor16</td><td style="text-align: right;;">1,003</td></tr><tr ><td style="color: #161120;text-align: center;">8</td><td style=";">Customer18 Distribuitor11</td><td style="text-align: right;;">276</td><td style="text-align: right;;"></td><td style=";">Distribuitor17</td><td style="text-align: right;;">2,370</td></tr><tr ><td style="color: #161120;text-align: center;">9</td><td style=";">Customer15 Distribuitor14</td><td style="text-align: right;;">545</td><td style="text-align: right;;"></td><td style=";">Distribuitor18</td><td style="text-align: right;;">684</td></tr><tr ><td style="color: #161120;text-align: center;">10</td><td style=";">Customer14 Distribuitor13</td><td style="text-align: right;;">894</td><td style="text-align: right;;"></td><td style=";">Distribuitor19</td><td style="text-align: right;;">1,222</td></tr><tr ><td style="color: #161120;text-align: center;">11</td><td style=";">Customer11 Distribuitor10</td><td style="text-align: right;;">714</td><td style="text-align: right;;"></td><td style=";">Distribuitor20</td><td style="text-align: right;;">921</td></tr><tr ><td style="color: #161120;text-align: center;">12</td><td style=";">Customer17 Distribuitor20</td><td style="text-align: right;;">716</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">13</td><td style=";">Customer11 Distribuitor17</td><td style="text-align: right;;">780</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">14</td><td style=";">Customer10 Distribuitor10</td><td style="text-align: right;;">599</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">15</td><td style=";">Customer19 Distribuitor18</td><td style="text-align: right;;">684</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">16</td><td style=";">Customer18 Distribuitor12</td><td style="text-align: right;;">770</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">17</td><td style=";">Customer18 Distribuitor15</td><td style="text-align: right;;">550</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">18</td><td style=";">Customer20 Distribuitor13</td><td style="text-align: right;;">123</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">19</td><td style=";">Customer17 Distribuitor13</td><td style="text-align: right;;">486</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">20</td><td style=";">Customer10 Distribuitor16</td><td style="text-align: right;;">348</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">21</td><td style=";">Customer12 Distribuitor17</td><td style="text-align: right;;">154</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">22</td><td style=";">Customer18 Distribuitor12</td><td style="text-align: right;;">454</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">23</td><td style=";">Customer10 Distribuitor12</td><td style="text-align: right;;">468</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">24</td><td style=";">Customer17 Distribuitor17</td><td style="text-align: right;;">612</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">25</td><td style=";">Customer10 Distribuitor20</td><td style="text-align: right;;">205</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">26</td><td style=";">Customer11 Distribuitor17</td><td style="text-align: right;;">340</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">27</td><td style=";">Customer14 Distribuitor17</td><td style="text-align: right;;">484</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">28</td><td style=";">Customer14 Distribuitor15</td><td style="text-align: right;;">608</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">29</td><td style=";">Customer19 Distribuitor15</td><td style="text-align: right;;">274</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">30</td><td style=";">Customer20 Distribuitor16</td><td style="text-align: right;;">655</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr></tbody></table><p style="width:3.6em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid #A6AAB6;border-top:none;text-align: center;background-color: #E0E0F0;color: #161120">Sheet1</p><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: #FFFFFF" ><tr><td style="padding:6px" ><b>Worksheet Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: #FFFFFF;border-collapse: collapse; border-color: #A6AAB6"><thead><tr style=" background-color: #E0E0F0;color: #161120"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">E2</th><td style="text-align:left">=SUMIF(<font color="Blue">A$2:A$30,"*"&D2&"*",B$2:B$30</font>)</td></tr></tbody></table></td></tr></table><br />
Markmzz
 
Upvote 0
Sumif wont work because I cant test for certain text in the string with a worksheet function. I did it in VBA using an event handler. Thank you
 
Upvote 0

Forum statistics

Threads
1,224,561
Messages
6,179,522
Members
452,923
Latest member
JackiG

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top