I keep a spreadsheet of my timeline at work and when I meet and expect to meet certain milestones. The data (dates) is stored left-to-right and each project has it's o开发者_C百科wn row. The milestones are permantely set and occupy Range(O:AA). My data is color coded as Green (Complete), Orange(Deadline), Blue(Not working on), Red(Not applicable).
What I would like to do is write a function that would check if a cell contained an orange color background(Color index 6) and return a TRUE or FALSE based on that. Basically I want to aggregate all of the deadlines across all of the columns. Eventually I would like to integrate a date check as well so I can see which deadlines are approaching.
Function ScanForColor(Dates As Range) as Boolean
If ScanForColor.Interior.ColorIndex = 6 Then
ScanForColor = True
Else
ScanForColor = False
End Function
I would like to call the function in a cell like =ScanForColor(O3:AA3) and I will have the ScanForColor function in column AB to hold the values for filtering the document.
Something like this will do the trick!
Function ScanForColor(Cells As Range, ColorValue As Integer) As Boolean
Dim cell As Range
For Each cell In Cells
If cell.Interior.ColorIndex = ColorValue Then
ScanForColor = True
Exit For
End If
Next
End Function
This will allow you to call and test different color values....
精彩评论