EastLondonGirl
New Member
- Joined
- Sep 2, 2014
- Messages
- 1
Hi there.
I've been searching for a solution for a Colorfunction problem. I'm using Excel 2010 and I'd like my cells to be counted by colour and number, and as some contain 0.5, the function I've been attempting to use counts it as a whole number only. To give you context, I am transferring a hiring plan from Powerpoint to Excel and the whole number equals a full time worker, whilst a 0.5 equals a part time worker. The colours illustrate where we are in the recruitment process, ie red equals searching, green equals placed.
Please see VBA code attempted below. Thank you in advance!
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've been searching for a solution for a Colorfunction problem. I'm using Excel 2010 and I'd like my cells to be counted by colour and number, and as some contain 0.5, the function I've been attempting to use counts it as a whole number only. To give you context, I am transferring a hiring plan from Powerpoint to Excel and the whole number equals a full time worker, whilst a 0.5 equals a part time worker. The colours illustrate where we are in the recruitment process, ie red equals searching, green equals placed.
Please see VBA code attempted below. Thank you in advance!
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