I am trying to calculate a range of cells by background color and date range. for instalce lets say i want to count all cells in column A that have a date range from 1/1/09-3/31/09 and that has the blue background fill color. Now i havea function created in vba:
Function ColorFunction(rColor As Range, rRange As Range, Optional SUM As Boolean)
Dim rCell As Range
Dim lCol As Long
Dim vResult
lCol = rColor.Interior.ColorIndex
If SUM = True Then
For Each rCell In rRange
If rCell.Interior.ColorIndex = lCol Then
vResult = WorksheetFunction.SUM(rCell, vResult)
End If
Next rCell
Else
For Each rCell In rRange
If rCell.Interior.ColorIndex = lCol Then
vResult = 1 + vResult
End If
Next rCell
End If
ColorFunction = vResult
End Function
I would normally take this and point it to a cell with the color i am trying to count and then let it go. so the fucntion works correctly. However I am trying to create and addition to this script where it now incorporate the count to specific date ranges i pick and not the whole row. for example I would have certain cells marked as color background blue with dates of 3/1 and 3/2 ect I need to count all these. Is this possible?"
Bookmarks