Brian R Armstrong
Board Regular
- Joined
- Jun 5, 2007
- Messages
- 92
The function below does not work with Conditional Format, but does with a Formatted cell
Is it possible to modify the code to make it work
Any help would be appreciated.
Kind Regards Brian A
Function CountByColor(CellColor As Range, SumRange As Range)
' CountByColor Function
' VBA and Macros for Microsoft Excel by Bill Jelen Mr.Excel, Page 84
' Modified 07/25/2011 by hiker95
' =CountByColor(J1,A1:G1)
' =CountByColor(cell_address_where_a_specific_color_is, range_to_Count)
Dim myCell As Range
Dim iCol As Integer
Dim myTotal
iCol = CellColor.Interior.ColorIndex
For Each myCell In SumRange
If myCell.Interior.ColorIndex = iCol Then
myTotal = myTotal + 1
End If
Next myCell
CountByColor = myTotal
End Function
Is it possible to modify the code to make it work
Any help would be appreciated.
Kind Regards Brian A
Function CountByColor(CellColor As Range, SumRange As Range)
' CountByColor Function
' VBA and Macros for Microsoft Excel by Bill Jelen Mr.Excel, Page 84
' Modified 07/25/2011 by hiker95
' =CountByColor(J1,A1:G1)
' =CountByColor(cell_address_where_a_specific_color_is, range_to_Count)
Dim myCell As Range
Dim iCol As Integer
Dim myTotal
iCol = CellColor.Interior.ColorIndex
For Each myCell In SumRange
If myCell.Interior.ColorIndex = iCol Then
myTotal = myTotal + 1
End If
Next myCell
CountByColor = myTotal
End Function