SandyG
New Member
- Joined
- Oct 4, 2013
- Messages
- 31
Good day! I have an Excel workbook that I am tracking labor costs, committed and actual. For the actual costs, I am using the "sumbycolor" code and it works great.
I need to be able to also create a formula based on cell color and date range. So, I think I need to use a "sumifs" with a "sumbycolor".
This is the code that I have in my module.
The code works great for summing anything by color. And updates as new cells are colored.
Here is what I'm looking for:
Jan has worked a total of 120 hours from 4/1/18 - 4/30/18, and we have been invoiced $3000 so far (the fields are colored in green to show the $3000 invoiced amount). There is still $2000 that has not been invoiced for the month, and they are not colored.
The formula would be: Sumif (the color of field is green) AND (date range is between 4/1/18 - 4/30/18).
Can anyone help?
I need to be able to also create a formula based on cell color and date range. So, I think I need to use a "sumifs" with a "sumbycolor".
This is the code that I have in my module.
Code:
Function SumByColor(CellColor As Range, SumRange As Range)
Application.Volatile
Dim ICol As Integer
Dim TCell As Range
ICol = CellColor.Interior.ColorIndex
For Each TCell In SumRange
If ICol = TCell.Interior.ColorIndex Then
SumByColor = SumByColor + TCell.Value
End If
Next TCell
End Function
The code works great for summing anything by color. And updates as new cells are colored.
Here is what I'm looking for:
Jan has worked a total of 120 hours from 4/1/18 - 4/30/18, and we have been invoiced $3000 so far (the fields are colored in green to show the $3000 invoiced amount). There is still $2000 that has not been invoiced for the month, and they are not colored.
The formula would be: Sumif (the color of field is green) AND (date range is between 4/1/18 - 4/30/18).
Can anyone help?