Hi,
It's kind of hard to come up with an appropriate title for what I want to do. I'm relatively new with VBA and I am trying to solve an issue. Sorry if the following data is a bit messy, but this is how it's suppose to end up looking like.
<table style="border-collapse: collapse; width: 412pt;" border="0" cellpadding="0" cellspacing="0" width="550"><col style="width: 48pt;" width="64" span="2"> <col style="width: 53pt;" width="71"> <col style="width: 48pt;" width="64"> <col style="width: 54pt;" width="72"> <col style="width: 59pt;" width="79"> <col style="width: 48pt;" width="64"> <col style="width: 54pt;" width="72"> <tbody><tr style="height: 12.75pt;" height="17"> <td class="xl67" style="height: 12.75pt; width: 48pt;" width="64" height="17">Company</td> <td style="width: 48pt;" width="64">Division</td> <td class="xl68" style="width: 53pt;" width="71">Date</td> <td class="xl69" style="width: 48pt;" width="64">Invoice</td> <td class="xl70" style="width: 54pt;" width="72">Amount</td> <td style="width: 59pt;" width="79">
</td> <td class="xl74" style="width: 48pt;" width="64">Number </td> <td class="xl75" style="width: 54pt;" width="72">Average</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl67" style="height: 12.75pt;" height="17">FP&L</td> <td>A</td> <td class="xl71" align="right">01/24/2005</td> <td align="right">2046</td> <td class="xl72"> 9,919.65 </td> <td>
</td> <td>
</td> <td class="xl66">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl67" style="height: 12.75pt;" height="17">FP&L</td> <td>A</td> <td class="xl71" align="right">04/24/2005</td> <td align="right">2202</td> <td class="xl72"> 10,187.77 </td> <td>
</td> <td>
</td> <td class="xl66">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl67" style="height: 12.75pt;" height="17">FP&L</td> <td>A</td> <td class="xl71" align="right">10/26/2005</td> <td align="right">2655</td> <td class="xl72"> 11,534.81 </td> <td>
</td> <td>
</td> <td class="xl66">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl67" style="height: 12.75pt;" height="17">FP&L</td> <td>A</td> <td class="xl71" align="right">10/31/2005</td> <td align="right">2726</td> <td class="xl72"> 11,666.62 </td> <td class="xl72"> 43,308.85 </td> <td class="xl69">4</td> <td class="xl76"> 10,827.21 </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl67" style="height: 12.75pt;" height="17">FP&L</td> <td>B</td> <td class="xl71" align="right">02/20/2005</td> <td align="right">2076</td> <td class="xl72"> 9,744.21 </td> <td>
</td> <td class="xl69">
</td> <td class="xl66">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl67" style="height: 12.75pt;" height="17">FP&L</td> <td>B</td> <td class="xl71" align="right">04/08/2005</td> <td align="right">2154</td> <td class="xl72"> 10,143.71 </td> <td>
</td> <td class="xl69">
</td> <td class="xl66">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl67" style="height: 12.75pt;" height="17">FP&L</td> <td>B</td> <td class="xl71" align="right">10/21/2005</td> <td align="right">2584</td> <td class="xl72"> 11,289.24 </td> <td>
</td> <td class="xl69">
</td> <td class="xl66">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl67" style="height: 12.75pt;" height="17">FP&L</td> <td>B</td> <td class="xl71" align="right">11/19/2005</td> <td align="right">2868</td> <td class="xl72"> 12,124.01 </td> <td class="xl72"> 43,301.17 </td> <td class="xl69">4</td> <td class="xl76"> 10,825.29 </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl67" style="height: 12.75pt;" height="17">FP&L</td> <td>C</td> <td class="xl71" align="right">02/05/2005</td> <td align="right">2061</td> <td class="xl72"> 9,764.32 </td> <td>
</td> <td class="xl69">
</td> <td class="xl66">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl67" style="height: 12.75pt;" height="17">FP&L</td> <td>C</td> <td class="xl71" align="right">05/12/2005</td> <td align="right">2250</td> <td class="xl72"> 10,431.84 </td> <td>
</td> <td class="xl69">
</td> <td class="xl66">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl67" style="height: 12.75pt;" height="17">FP&L</td> <td>C</td> <td class="xl71" align="right">06/27/2005</td> <td align="right">2346</td> <td class="xl72"> 10,819.97 </td> <td>
</td> <td class="xl69">
</td> <td class="xl66">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl67" style="height: 12.75pt;" height="17">FP&L</td> <td>C</td> <td class="xl71" align="right">12/10/2005</td> <td align="right">3010</td> <td class="xl72"> 12,712.64 </td> <td class="xl72"> 43,728.77 </td> <td class="xl69">4</td> <td class="xl76"> 10,932.19 </td> </tr> <tr style="height: 13.5pt;" height="18"> <td class="xl67" style="height: 13.5pt;" height="18">
</td> <td>
</td> <td class="xl71">
</td> <td>
</td> <td class="xl72">
</td> <td class="xl72">
</td> <td class="xl69">
</td> <td class="xl66">
</td> </tr> <tr style="height: 14.25pt;" height="19"> <td class="xl67" style="height: 14.25pt;" height="19">Total</td> <td>FP&L</td> <td class="xl71">
</td> <td>
</td> <td class="xl72">
</td> <td class="xl65"> 130,338.79 </td> <td class="xl69">
</td> <td class="xl66">
</td> </tr> <tr style="height: 13.5pt;" height="18"> <td class="xl67" style="height: 13.5pt;" height="18">
</td> <td>
</td> <td class="xl71">
</td> <td>
</td> <td class="xl72">
</td> <td class="xl73">
</td> <td class="xl69">
</td> <td class="xl66">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl67" style="height: 12.75pt;" height="17">Miami Dade</td> <td>AA</td> <td class="xl71" align="right">03/07/2005</td> <td align="right">2091</td> <td class="xl72"> 9,879.35 </td> <td class="xl73">
</td> <td class="xl69">
</td> <td class="xl66">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl67" style="height: 12.75pt;" height="17">Miami Dade</td> <td>AA</td> <td class="xl71" align="right">11/14/2005</td> <td align="right">2797</td> <td class="xl72"> 11,998.44 </td> <td class="xl73">
</td> <td class="xl69">
</td> <td class="xl66">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl67" style="height: 12.75pt;" height="17">Miami Dade</td> <td>AA</td> <td class="xl71" align="right">12/05/2005</td> <td align="right">2939</td> <td class="xl72"> 12,532.57 </td> <td class="xl73"> 34,410.36 </td> <td class="xl69">3</td> <td class="xl76"> 11,470.12 </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl67" style="height: 12.75pt;" height="17">Miami Dade</td> <td>BB</td> <td class="xl71" align="right">01/15/2005</td> <td align="right">2016</td> <td class="xl72"> 9,554.21 </td> <td class="xl73">
</td> <td class="xl69">
</td> <td class="xl66">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl67" style="height: 12.75pt;" height="17">Miami Dade</td> <td>BB</td> <td class="xl71" align="right">03/25/2005</td> <td align="right">2106</td> <td class="xl72"> 9,849.98 </td> <td class="xl73">
</td> <td class="xl69">
</td> <td class="xl66">
</td> </tr> <tr style="height: 13.5pt;" height="18"> <td class="xl67" style="height: 13.5pt;" height="18">Miami Dade</td> <td>BB</td> <td class="xl71" align="right">07/21/2005</td> <td align="right">2394</td> <td class="xl72"> 10,676.54 </td> <td class="xl73"> 30,080.73 </td> <td class="xl69">3</td> <td class="xl76"> 10,026.91 </td> </tr> <tr style="height: 14.25pt;" height="19"> <td class="xl67" style="height: 14.25pt;" height="19">Total</td> <td colspan="2" style="">Miami Dade</td> <td>
</td> <td class="xl72">
</td> <td class="xl65"> 64,491.09 </td> <td class="xl69">
</td> <td class="xl66">
</td> </tr> <tr style="height: 13.5pt;" height="18"> <td class="xl67" style="height: 13.5pt;" height="18">
</td> <td>
</td> <td class="xl71">
</td> <td>
</td> <td class="xl72">
</td> <td class="xl73">
</td> <td class="xl69">
</td> <td class="xl66">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl67" style="height: 12.75pt;" height="17">Pearson</td> <td>BBB</td> <td class="xl71" align="right">06/03/2005</td> <td align="right">2298</td> <td class="xl72"> 10,388.41 </td> <td class="xl73"> 10,388.41 </td> <td class="xl69">1</td> <td class="xl76"> 10,388.41 </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl67" style="height: 12.75pt;" height="17">Pearson</td> <td>CCC</td> <td class="xl71" align="right">01/18/2005</td> <td align="right">2031</td> <td class="xl72"> 9,799.35 </td> <td class="xl73">
</td> <td class="xl69">
</td> <td class="xl66">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl67" style="height: 12.75pt;" height="17">Pearson</td> <td>CCC</td> <td class="xl71" align="right">08/14/2005</td> <td align="right">2442</td> <td class="xl72"> 10,933.11 </td> <td class="xl73"> 20,732.46 </td> <td class="xl69">2</td> <td class="xl76"> 10,366.23 </td> </tr> <tr style="height: 13.5pt;" height="18"> <td class="xl67" style="height: 13.5pt;" height="18">Pearson</td> <td>DDD</td> <td class="xl71" align="right">09/07/2005</td> <td align="right">2513</td> <td class="xl72"> 11,246.17 </td> <td class="xl73"> 11,246.17 </td> <td class="xl69">1</td> <td class="xl76"> 11,246.17 </td> </tr> <tr style="height: 14.25pt;" height="19"> <td class="xl67" style="height: 14.25pt;" height="19">Total</td> <td>Pearson</td> <td class="xl71">
</td> <td>
</td> <td class="xl72">
</td> <td class="xl65"> 42,367.04 </td> <td>
</td> <td class="xl66">
</td> </tr> <tr style="height: 14.25pt;" height="19"> <td class="xl67" style="height: 14.25pt;" height="19">
</td> <td>
</td> <td class="xl71">
</td> <td>
</td> <td class="xl72">
</td> <td class="xl73">
</td> <td>
</td> <td class="xl66">
</td> </tr> <tr style="height: 14.25pt;" height="19"> <td class="xl67" colspan="2" style="height: 14.25pt;" height="19">Grand Total</td> <td class="xl71">
</td> <td>
</td> <td class="xl72">
</td> <td class="xl65"> 237,196.92 </td> <td align="right">22</td> <td class="xl76"> 10,781.68 </td> </tr> </tbody></table>
I wrote a macro that will get the subtotals of amounts by divison (A, B, C, etc...), but then I'm stuck when I'm trying to get it to count the number of A's, B's, etc so it could then make a number column. For example, if I add two more A's to the data, the number 6 will appear under the number column. Then it will start counting the number of B's, and put a 4 at the end of the data (because there are 4 B's), and start again with C.
Here is the code I used to do the subtotals for the amounts related to each division. I am trying to adapt it in some way so it counts the number of A's, B's, and C's as mentioned previously. I don't know if it's in any way useful.
<table style="border-collapse: collapse; width: 412pt;" border="0" cellpadding="0" cellspacing="0" width="550"><col style="width: 48pt;" width="64" span="2"> <col style="width: 53pt;" width="71"> <col style="width: 48pt;" width="64"> <col style="width: 54pt;" width="72"> <col style="width: 59pt;" width="79"> <col style="width: 48pt;" width="64"> <col style="width: 54pt;" width="72"> <tbody><tr style="height: 12.75pt;" height="17"> <td class="xl65" style="height: 12.75pt; width: 48pt;" width="64" height="17">Application.Goto Reference:="Division"
ActiveCell.Offset(1, 0).Range("A1").Select
Do While ActiveCell <> ""
MydivisionSales = 0
Mydivision = ActiveCell
Do While ActiveCell = Mydivision
ActiveCell.Offset(0, 3).Range("A1").Select
If ActiveCell > 0 Then
MydivisionSales = MydivisionSales + ActiveCell
ActiveCell.Offset(1, 0).Range("A1").Select
Else
'Do Nothing
End If
ActiveCell.Offset(0, -3).Range("A1").Select
Loop
'Temp1 Macro
ActiveCell.Offset(-1, 4).Range("A1").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-12]C[-1]:R[-1]C[-1])"
ActiveCell.FormulaR1C1 = MydivisionSales
ActiveCell.Select
Selection.Style = "Comma"
Selection.Style = "Currency"
ActiveCell.Offset(1, -4).Range("A1").Select
'End Temp1 Macro
Loop
ActiveCell.Offset(3, 0).Range("A1").Select
Do While ActiveCell <> ""
MydivisionSales = 0
Mydivision = ActiveCell
Do While ActiveCell = Mydivision
ActiveCell.Offset(0, 3).Range("A1").Select
If ActiveCell > 0 Then
MydivisionSales = MydivisionSales + ActiveCell
ActiveCell.Offset(1, 0).Range("A1").Select
Else
'Do Nothing
End If
ActiveCell.Offset(0, -3).Range("A1").Select
Loop
'Temp1 Macro
ActiveCell.Offset(-1, 4).Range("A1").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-12]C[-1]:R[-1]C[-1])"
ActiveCell.FormulaR1C1 = MydivisionSales
ActiveCell.Select
Selection.Style = "Comma"
Selection.Style = "Currency"
ActiveCell.Offset(1, -4).Range("A1").Select
'End Temp1 Macro
Loop
ActiveCell.Offset(3, 0).Range("A1").Select
Do While ActiveCell <> ""
MydivisionSales = 0
Mydivision = ActiveCell
Do While ActiveCell = Mydivision
ActiveCell.Offset(0, 3).Range("A1").Select
If ActiveCell > 0 Then
MydivisionSales = MydivisionSales + ActiveCell
ActiveCell.Offset(1, 0).Range("A1").Select
Else
'Do Nothing
End If
ActiveCell.Offset(0, -3).Range("A1").Select
Loop
'Temp1 Macro
ActiveCell.Offset(-1, 4).Range("A1").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-12]C[-1]:R[-1]C[-1])"
ActiveCell.FormulaR1C1 = MydivisionSales
ActiveCell.Select
Selection.Style = "Comma"
Selection.Style = "Currency"
ActiveCell.Offset(1, -4).Range("A1").Select
'End Temp1 Macro
Loop
End Sub
</td> <td style="width: 48pt;" width="64">
</td> <td class="xl66" style="width: 53pt;" width="71">
</td> <td class="xl67" style="width: 48pt;" width="64">
</td> <td class="xl68" style="width: 54pt;" width="72">
</td> <td style="width: 59pt;" width="79">
</td> <td class="xl72" style="width: 48pt;" width="64">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl65" style="height: 12.75pt;" height="17">
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td>
</td> <td>
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl65" style="height: 12.75pt;" height="17">
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td>
</td> <td>
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl65" style="height: 12.75pt;" height="17">
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td>
</td> <td>
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl65" style="height: 12.75pt;" height="17">Sorry for the long post! Thanks!!!
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td class="xl70">
</td> <td class="xl67">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl65" style="height: 12.75pt;" height="17">
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td>
</td> <td class="xl67">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl65" style="height: 12.75pt;" height="17">
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td>
</td> <td class="xl67">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl65" style="height: 12.75pt;" height="17">
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td>
</td> <td class="xl67">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl65" style="height: 12.75pt;" height="17">
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td class="xl70">
</td> <td class="xl67">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl65" style="height: 12.75pt;" height="17">
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td>
</td> <td class="xl67">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl65" style="height: 12.75pt;" height="17">
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td>
</td> <td class="xl67">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl65" style="height: 12.75pt;" height="17">
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td>
</td> <td class="xl67">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl65" style="height: 12.75pt;" height="17">
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td class="xl70">
</td> <td class="xl67">
</td> </tr> <tr style="height: 13.5pt;" height="18"> <td class="xl65" style="height: 13.5pt;" height="18">
</td> <td>
</td> <td class="xl69">
</td> <td>
</td> <td class="xl70">
</td> <td class="xl70">
</td> <td class="xl67">
</td> </tr> <tr style="height: 14.25pt;" height="19"> <td class="xl65" style="height: 14.25pt;" height="19">
</td> <td>
</td> <td class="xl69">
</td> <td>
</td> <td class="xl70">
</td> <td class="xl63">
</td> <td class="xl67">
</td> </tr> <tr style="height: 13.5pt;" height="18"> <td class="xl65" style="height: 13.5pt;" height="18">
</td> <td>
</td> <td class="xl69">
</td> <td>
</td> <td class="xl70">
</td> <td class="xl71">
</td> <td class="xl67">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl65" style="height: 12.75pt;" height="17">
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td class="xl71">
</td> <td class="xl67">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl65" style="height: 12.75pt;" height="17">
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td class="xl71">
</td> <td class="xl67">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl65" style="height: 12.75pt;" height="17">
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td class="xl71">
</td> <td class="xl67">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl65" style="height: 12.75pt;" height="17">
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td class="xl71">
</td> <td class="xl67">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl65" style="height: 12.75pt;" height="17">
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td class="xl71">
</td> <td class="xl67">
</td> </tr> <tr style="height: 13.5pt;" height="18"> <td class="xl65" style="height: 13.5pt;" height="18">
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td class="xl71">
</td> <td class="xl67">
</td> </tr> <tr style="height: 14.25pt;" height="19"> <td class="xl65" style="height: 14.25pt;" height="19">
</td> <td colspan="2" style="">
</td> <td>
</td> <td class="xl70">
</td> <td class="xl63">
</td> <td class="xl67">
</td> </tr> <tr style="height: 13.5pt;" height="18"> <td class="xl65" style="height: 13.5pt;" height="18">
</td> <td>
</td> <td class="xl69">
</td> <td>
</td> <td class="xl70">
</td> <td class="xl71">
</td> <td class="xl67">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl65" style="height: 12.75pt;" height="17">
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td class="xl71">
</td> <td class="xl67">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl65" style="height: 12.75pt;" height="17">
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td class="xl71">
</td> <td class="xl67">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl65" style="height: 12.75pt;" height="17">
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td class="xl71">
</td> <td class="xl67">
</td> </tr> <tr style="height: 13.5pt;" height="18"> <td class="xl65" style="height: 13.5pt;" height="18">
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td class="xl71">
</td> <td class="xl67">
</td> </tr> <tr style="height: 14.25pt;" height="19"> <td class="xl65" style="height: 14.25pt;" height="19">
</td> <td>
</td> <td class="xl69">
</td> <td>
</td> <td class="xl70">
</td> <td class="xl63">
</td> <td>
</td> </tr> <tr style="height: 14.25pt;" height="19"> <td class="xl65" style="height: 14.25pt;" height="19">
</td> <td>
</td> <td class="xl69">
</td> <td>
</td> <td class="xl70">
</td> <td class="xl71">
</td> <td>
</td> </tr> </tbody></table>
It's kind of hard to come up with an appropriate title for what I want to do. I'm relatively new with VBA and I am trying to solve an issue. Sorry if the following data is a bit messy, but this is how it's suppose to end up looking like.
<table style="border-collapse: collapse; width: 412pt;" border="0" cellpadding="0" cellspacing="0" width="550"><col style="width: 48pt;" width="64" span="2"> <col style="width: 53pt;" width="71"> <col style="width: 48pt;" width="64"> <col style="width: 54pt;" width="72"> <col style="width: 59pt;" width="79"> <col style="width: 48pt;" width="64"> <col style="width: 54pt;" width="72"> <tbody><tr style="height: 12.75pt;" height="17"> <td class="xl67" style="height: 12.75pt; width: 48pt;" width="64" height="17">Company</td> <td style="width: 48pt;" width="64">Division</td> <td class="xl68" style="width: 53pt;" width="71">Date</td> <td class="xl69" style="width: 48pt;" width="64">Invoice</td> <td class="xl70" style="width: 54pt;" width="72">Amount</td> <td style="width: 59pt;" width="79">
</td> <td class="xl74" style="width: 48pt;" width="64">Number </td> <td class="xl75" style="width: 54pt;" width="72">Average</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl67" style="height: 12.75pt;" height="17">FP&L</td> <td>A</td> <td class="xl71" align="right">01/24/2005</td> <td align="right">2046</td> <td class="xl72"> 9,919.65 </td> <td>
</td> <td>
</td> <td class="xl66">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl67" style="height: 12.75pt;" height="17">FP&L</td> <td>A</td> <td class="xl71" align="right">04/24/2005</td> <td align="right">2202</td> <td class="xl72"> 10,187.77 </td> <td>
</td> <td>
</td> <td class="xl66">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl67" style="height: 12.75pt;" height="17">FP&L</td> <td>A</td> <td class="xl71" align="right">10/26/2005</td> <td align="right">2655</td> <td class="xl72"> 11,534.81 </td> <td>
</td> <td>
</td> <td class="xl66">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl67" style="height: 12.75pt;" height="17">FP&L</td> <td>A</td> <td class="xl71" align="right">10/31/2005</td> <td align="right">2726</td> <td class="xl72"> 11,666.62 </td> <td class="xl72"> 43,308.85 </td> <td class="xl69">4</td> <td class="xl76"> 10,827.21 </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl67" style="height: 12.75pt;" height="17">FP&L</td> <td>B</td> <td class="xl71" align="right">02/20/2005</td> <td align="right">2076</td> <td class="xl72"> 9,744.21 </td> <td>
</td> <td class="xl69">
</td> <td class="xl66">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl67" style="height: 12.75pt;" height="17">FP&L</td> <td>B</td> <td class="xl71" align="right">04/08/2005</td> <td align="right">2154</td> <td class="xl72"> 10,143.71 </td> <td>
</td> <td class="xl69">
</td> <td class="xl66">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl67" style="height: 12.75pt;" height="17">FP&L</td> <td>B</td> <td class="xl71" align="right">10/21/2005</td> <td align="right">2584</td> <td class="xl72"> 11,289.24 </td> <td>
</td> <td class="xl69">
</td> <td class="xl66">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl67" style="height: 12.75pt;" height="17">FP&L</td> <td>B</td> <td class="xl71" align="right">11/19/2005</td> <td align="right">2868</td> <td class="xl72"> 12,124.01 </td> <td class="xl72"> 43,301.17 </td> <td class="xl69">4</td> <td class="xl76"> 10,825.29 </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl67" style="height: 12.75pt;" height="17">FP&L</td> <td>C</td> <td class="xl71" align="right">02/05/2005</td> <td align="right">2061</td> <td class="xl72"> 9,764.32 </td> <td>
</td> <td class="xl69">
</td> <td class="xl66">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl67" style="height: 12.75pt;" height="17">FP&L</td> <td>C</td> <td class="xl71" align="right">05/12/2005</td> <td align="right">2250</td> <td class="xl72"> 10,431.84 </td> <td>
</td> <td class="xl69">
</td> <td class="xl66">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl67" style="height: 12.75pt;" height="17">FP&L</td> <td>C</td> <td class="xl71" align="right">06/27/2005</td> <td align="right">2346</td> <td class="xl72"> 10,819.97 </td> <td>
</td> <td class="xl69">
</td> <td class="xl66">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl67" style="height: 12.75pt;" height="17">FP&L</td> <td>C</td> <td class="xl71" align="right">12/10/2005</td> <td align="right">3010</td> <td class="xl72"> 12,712.64 </td> <td class="xl72"> 43,728.77 </td> <td class="xl69">4</td> <td class="xl76"> 10,932.19 </td> </tr> <tr style="height: 13.5pt;" height="18"> <td class="xl67" style="height: 13.5pt;" height="18">
</td> <td>
</td> <td class="xl71">
</td> <td>
</td> <td class="xl72">
</td> <td class="xl72">
</td> <td class="xl69">
</td> <td class="xl66">
</td> </tr> <tr style="height: 14.25pt;" height="19"> <td class="xl67" style="height: 14.25pt;" height="19">Total</td> <td>FP&L</td> <td class="xl71">
</td> <td>
</td> <td class="xl72">
</td> <td class="xl65"> 130,338.79 </td> <td class="xl69">
</td> <td class="xl66">
</td> </tr> <tr style="height: 13.5pt;" height="18"> <td class="xl67" style="height: 13.5pt;" height="18">
</td> <td>
</td> <td class="xl71">
</td> <td>
</td> <td class="xl72">
</td> <td class="xl73">
</td> <td class="xl69">
</td> <td class="xl66">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl67" style="height: 12.75pt;" height="17">Miami Dade</td> <td>AA</td> <td class="xl71" align="right">03/07/2005</td> <td align="right">2091</td> <td class="xl72"> 9,879.35 </td> <td class="xl73">
</td> <td class="xl69">
</td> <td class="xl66">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl67" style="height: 12.75pt;" height="17">Miami Dade</td> <td>AA</td> <td class="xl71" align="right">11/14/2005</td> <td align="right">2797</td> <td class="xl72"> 11,998.44 </td> <td class="xl73">
</td> <td class="xl69">
</td> <td class="xl66">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl67" style="height: 12.75pt;" height="17">Miami Dade</td> <td>AA</td> <td class="xl71" align="right">12/05/2005</td> <td align="right">2939</td> <td class="xl72"> 12,532.57 </td> <td class="xl73"> 34,410.36 </td> <td class="xl69">3</td> <td class="xl76"> 11,470.12 </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl67" style="height: 12.75pt;" height="17">Miami Dade</td> <td>BB</td> <td class="xl71" align="right">01/15/2005</td> <td align="right">2016</td> <td class="xl72"> 9,554.21 </td> <td class="xl73">
</td> <td class="xl69">
</td> <td class="xl66">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl67" style="height: 12.75pt;" height="17">Miami Dade</td> <td>BB</td> <td class="xl71" align="right">03/25/2005</td> <td align="right">2106</td> <td class="xl72"> 9,849.98 </td> <td class="xl73">
</td> <td class="xl69">
</td> <td class="xl66">
</td> </tr> <tr style="height: 13.5pt;" height="18"> <td class="xl67" style="height: 13.5pt;" height="18">Miami Dade</td> <td>BB</td> <td class="xl71" align="right">07/21/2005</td> <td align="right">2394</td> <td class="xl72"> 10,676.54 </td> <td class="xl73"> 30,080.73 </td> <td class="xl69">3</td> <td class="xl76"> 10,026.91 </td> </tr> <tr style="height: 14.25pt;" height="19"> <td class="xl67" style="height: 14.25pt;" height="19">Total</td> <td colspan="2" style="">Miami Dade</td> <td>
</td> <td class="xl72">
</td> <td class="xl65"> 64,491.09 </td> <td class="xl69">
</td> <td class="xl66">
</td> </tr> <tr style="height: 13.5pt;" height="18"> <td class="xl67" style="height: 13.5pt;" height="18">
</td> <td>
</td> <td class="xl71">
</td> <td>
</td> <td class="xl72">
</td> <td class="xl73">
</td> <td class="xl69">
</td> <td class="xl66">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl67" style="height: 12.75pt;" height="17">Pearson</td> <td>BBB</td> <td class="xl71" align="right">06/03/2005</td> <td align="right">2298</td> <td class="xl72"> 10,388.41 </td> <td class="xl73"> 10,388.41 </td> <td class="xl69">1</td> <td class="xl76"> 10,388.41 </td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl67" style="height: 12.75pt;" height="17">Pearson</td> <td>CCC</td> <td class="xl71" align="right">01/18/2005</td> <td align="right">2031</td> <td class="xl72"> 9,799.35 </td> <td class="xl73">
</td> <td class="xl69">
</td> <td class="xl66">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl67" style="height: 12.75pt;" height="17">Pearson</td> <td>CCC</td> <td class="xl71" align="right">08/14/2005</td> <td align="right">2442</td> <td class="xl72"> 10,933.11 </td> <td class="xl73"> 20,732.46 </td> <td class="xl69">2</td> <td class="xl76"> 10,366.23 </td> </tr> <tr style="height: 13.5pt;" height="18"> <td class="xl67" style="height: 13.5pt;" height="18">Pearson</td> <td>DDD</td> <td class="xl71" align="right">09/07/2005</td> <td align="right">2513</td> <td class="xl72"> 11,246.17 </td> <td class="xl73"> 11,246.17 </td> <td class="xl69">1</td> <td class="xl76"> 11,246.17 </td> </tr> <tr style="height: 14.25pt;" height="19"> <td class="xl67" style="height: 14.25pt;" height="19">Total</td> <td>Pearson</td> <td class="xl71">
</td> <td>
</td> <td class="xl72">
</td> <td class="xl65"> 42,367.04 </td> <td>
</td> <td class="xl66">
</td> </tr> <tr style="height: 14.25pt;" height="19"> <td class="xl67" style="height: 14.25pt;" height="19">
</td> <td>
</td> <td class="xl71">
</td> <td>
</td> <td class="xl72">
</td> <td class="xl73">
</td> <td>
</td> <td class="xl66">
</td> </tr> <tr style="height: 14.25pt;" height="19"> <td class="xl67" colspan="2" style="height: 14.25pt;" height="19">Grand Total</td> <td class="xl71">
</td> <td>
</td> <td class="xl72">
</td> <td class="xl65"> 237,196.92 </td> <td align="right">22</td> <td class="xl76"> 10,781.68 </td> </tr> </tbody></table>
I wrote a macro that will get the subtotals of amounts by divison (A, B, C, etc...), but then I'm stuck when I'm trying to get it to count the number of A's, B's, etc so it could then make a number column. For example, if I add two more A's to the data, the number 6 will appear under the number column. Then it will start counting the number of B's, and put a 4 at the end of the data (because there are 4 B's), and start again with C.
Here is the code I used to do the subtotals for the amounts related to each division. I am trying to adapt it in some way so it counts the number of A's, B's, and C's as mentioned previously. I don't know if it's in any way useful.
<table style="border-collapse: collapse; width: 412pt;" border="0" cellpadding="0" cellspacing="0" width="550"><col style="width: 48pt;" width="64" span="2"> <col style="width: 53pt;" width="71"> <col style="width: 48pt;" width="64"> <col style="width: 54pt;" width="72"> <col style="width: 59pt;" width="79"> <col style="width: 48pt;" width="64"> <col style="width: 54pt;" width="72"> <tbody><tr style="height: 12.75pt;" height="17"> <td class="xl65" style="height: 12.75pt; width: 48pt;" width="64" height="17">Application.Goto Reference:="Division"
ActiveCell.Offset(1, 0).Range("A1").Select
Do While ActiveCell <> ""
MydivisionSales = 0
Mydivision = ActiveCell
Do While ActiveCell = Mydivision
ActiveCell.Offset(0, 3).Range("A1").Select
If ActiveCell > 0 Then
MydivisionSales = MydivisionSales + ActiveCell
ActiveCell.Offset(1, 0).Range("A1").Select
Else
'Do Nothing
End If
ActiveCell.Offset(0, -3).Range("A1").Select
Loop
'Temp1 Macro
ActiveCell.Offset(-1, 4).Range("A1").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-12]C[-1]:R[-1]C[-1])"
ActiveCell.FormulaR1C1 = MydivisionSales
ActiveCell.Select
Selection.Style = "Comma"
Selection.Style = "Currency"
ActiveCell.Offset(1, -4).Range("A1").Select
'End Temp1 Macro
Loop
ActiveCell.Offset(3, 0).Range("A1").Select
Do While ActiveCell <> ""
MydivisionSales = 0
Mydivision = ActiveCell
Do While ActiveCell = Mydivision
ActiveCell.Offset(0, 3).Range("A1").Select
If ActiveCell > 0 Then
MydivisionSales = MydivisionSales + ActiveCell
ActiveCell.Offset(1, 0).Range("A1").Select
Else
'Do Nothing
End If
ActiveCell.Offset(0, -3).Range("A1").Select
Loop
'Temp1 Macro
ActiveCell.Offset(-1, 4).Range("A1").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-12]C[-1]:R[-1]C[-1])"
ActiveCell.FormulaR1C1 = MydivisionSales
ActiveCell.Select
Selection.Style = "Comma"
Selection.Style = "Currency"
ActiveCell.Offset(1, -4).Range("A1").Select
'End Temp1 Macro
Loop
ActiveCell.Offset(3, 0).Range("A1").Select
Do While ActiveCell <> ""
MydivisionSales = 0
Mydivision = ActiveCell
Do While ActiveCell = Mydivision
ActiveCell.Offset(0, 3).Range("A1").Select
If ActiveCell > 0 Then
MydivisionSales = MydivisionSales + ActiveCell
ActiveCell.Offset(1, 0).Range("A1").Select
Else
'Do Nothing
End If
ActiveCell.Offset(0, -3).Range("A1").Select
Loop
'Temp1 Macro
ActiveCell.Offset(-1, 4).Range("A1").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-12]C[-1]:R[-1]C[-1])"
ActiveCell.FormulaR1C1 = MydivisionSales
ActiveCell.Select
Selection.Style = "Comma"
Selection.Style = "Currency"
ActiveCell.Offset(1, -4).Range("A1").Select
'End Temp1 Macro
Loop
End Sub
</td> <td style="width: 48pt;" width="64">
</td> <td class="xl66" style="width: 53pt;" width="71">
</td> <td class="xl67" style="width: 48pt;" width="64">
</td> <td class="xl68" style="width: 54pt;" width="72">
</td> <td style="width: 59pt;" width="79">
</td> <td class="xl72" style="width: 48pt;" width="64">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl65" style="height: 12.75pt;" height="17">
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td>
</td> <td>
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl65" style="height: 12.75pt;" height="17">
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td>
</td> <td>
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl65" style="height: 12.75pt;" height="17">
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td>
</td> <td>
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl65" style="height: 12.75pt;" height="17">Sorry for the long post! Thanks!!!
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td class="xl70">
</td> <td class="xl67">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl65" style="height: 12.75pt;" height="17">
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td>
</td> <td class="xl67">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl65" style="height: 12.75pt;" height="17">
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td>
</td> <td class="xl67">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl65" style="height: 12.75pt;" height="17">
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td>
</td> <td class="xl67">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl65" style="height: 12.75pt;" height="17">
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td class="xl70">
</td> <td class="xl67">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl65" style="height: 12.75pt;" height="17">
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td>
</td> <td class="xl67">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl65" style="height: 12.75pt;" height="17">
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td>
</td> <td class="xl67">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl65" style="height: 12.75pt;" height="17">
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td>
</td> <td class="xl67">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl65" style="height: 12.75pt;" height="17">
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td class="xl70">
</td> <td class="xl67">
</td> </tr> <tr style="height: 13.5pt;" height="18"> <td class="xl65" style="height: 13.5pt;" height="18">
</td> <td>
</td> <td class="xl69">
</td> <td>
</td> <td class="xl70">
</td> <td class="xl70">
</td> <td class="xl67">
</td> </tr> <tr style="height: 14.25pt;" height="19"> <td class="xl65" style="height: 14.25pt;" height="19">
</td> <td>
</td> <td class="xl69">
</td> <td>
</td> <td class="xl70">
</td> <td class="xl63">
</td> <td class="xl67">
</td> </tr> <tr style="height: 13.5pt;" height="18"> <td class="xl65" style="height: 13.5pt;" height="18">
</td> <td>
</td> <td class="xl69">
</td> <td>
</td> <td class="xl70">
</td> <td class="xl71">
</td> <td class="xl67">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl65" style="height: 12.75pt;" height="17">
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td class="xl71">
</td> <td class="xl67">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl65" style="height: 12.75pt;" height="17">
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td class="xl71">
</td> <td class="xl67">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl65" style="height: 12.75pt;" height="17">
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td class="xl71">
</td> <td class="xl67">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl65" style="height: 12.75pt;" height="17">
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td class="xl71">
</td> <td class="xl67">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl65" style="height: 12.75pt;" height="17">
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td class="xl71">
</td> <td class="xl67">
</td> </tr> <tr style="height: 13.5pt;" height="18"> <td class="xl65" style="height: 13.5pt;" height="18">
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td class="xl71">
</td> <td class="xl67">
</td> </tr> <tr style="height: 14.25pt;" height="19"> <td class="xl65" style="height: 14.25pt;" height="19">
</td> <td colspan="2" style="">
</td> <td>
</td> <td class="xl70">
</td> <td class="xl63">
</td> <td class="xl67">
</td> </tr> <tr style="height: 13.5pt;" height="18"> <td class="xl65" style="height: 13.5pt;" height="18">
</td> <td>
</td> <td class="xl69">
</td> <td>
</td> <td class="xl70">
</td> <td class="xl71">
</td> <td class="xl67">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl65" style="height: 12.75pt;" height="17">
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td class="xl71">
</td> <td class="xl67">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl65" style="height: 12.75pt;" height="17">
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td class="xl71">
</td> <td class="xl67">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td class="xl65" style="height: 12.75pt;" height="17">
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td class="xl71">
</td> <td class="xl67">
</td> </tr> <tr style="height: 13.5pt;" height="18"> <td class="xl65" style="height: 13.5pt;" height="18">
</td> <td>
</td> <td class="xl69" align="right">
</td> <td align="right">
</td> <td class="xl70">
</td> <td class="xl71">
</td> <td class="xl67">
</td> </tr> <tr style="height: 14.25pt;" height="19"> <td class="xl65" style="height: 14.25pt;" height="19">
</td> <td>
</td> <td class="xl69">
</td> <td>
</td> <td class="xl70">
</td> <td class="xl63">
</td> <td>
</td> </tr> <tr style="height: 14.25pt;" height="19"> <td class="xl65" style="height: 14.25pt;" height="19">
</td> <td>
</td> <td class="xl69">
</td> <td>
</td> <td class="xl70">
</td> <td class="xl71">
</td> <td>
</td> </tr> </tbody></table>