Hi
Try the following macro. You need to set the bits that have been marked
with '********* before you run it, and please save first. It will output a
table below your data, with 01,02,03... in the A column, the one color sum in
the B column, and the other color sum in the C column.
The parameters are:
MySh1 is the sheet where all this data is.
MyStartRow is the row number of the first entry of your database
MyEndRow is the row number of the last entry of your database
MyCheckCol is the column number with the data which starts with 01,02,...
MySumCol is the column number with the numbers to sum
MyColor(i) is the color index you want to sum over (can be increased from
just two colors if you want)
The three rows above the next c and next s just set up the table, and can be
adapted for however you want the data to be outputted.
Regards
Glenton
www.leviqqio.com
Sub MySum()
Dim MySum As Double
Dim MyColor(1)
Dim MySh1 As Worksheet
Set MySh1 = Sheets("Sheet2") '**************
MyStartRow = 3 '**************
MyEndRow = 18 '**************
MyCheckCol = 1 '**************
MySumCol = 10 '**************
MyColor(0) = 7 '**************
MyColor(1) = 6 '**************
For s = 1 To 99
MySearch = Right("0" & s, 2) 'this will give you the 01,02,03...
For c = 0 To 1
MySum = 0
For i = MyStartRow To MyEndRow
If Left(MySh1.Cells(i, MyCheckCol), 2) = MySearch Then
If MySh1.Cells(i, MyCheckCol).Interior.ColorIndex = MyColor(c) Then
MySum = MySum + MySh1.Cells(i, MySumCol) 'or whatever you're summing
End If
End If
Next i
MySh1.Cells(MyEndRow + s + 1, c + 2) = MySum 'save the final sum
MySh1.Cells(MyEndRow + s + 1, c + 2).Interior.ColorIndex = MyColor(c)
MySh1.Cells(MyEndRow + s + 1, 1) = "'" & MySearch
Next c
Next s
End Sub