Function CountColor(range_data As Range, criteria As Range) As Long
Application.Volatile (True)
Dim datax As Range
Dim xcolor As Long
xcolor = criteria.Interior.ColorIndex
For Each datax In range_data
If datax.Interior.ColorIndex = xcolor Then
CountColor = CountColor + 1
End If
Next datax
End Function
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Static LastRange As Range 'The last range selected
Static LastColorIndex As Integer 'The color index of the last range selected
If LastRange.Cells(1).Interior.ColorIndex <> LastColorIndex Then
Worksheets("Sheet1").Calculate
.Calculate
End If
Set LastRange = Target
LastColorIndex = Target.Interior.ColorIndex
End Sub
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE