counting by colour only if a cell contains a date???

  • Thread starter Thread starter Simon Lloyd
  • Start date Start date
S

Simon Lloyd

Sorry Peter you have lost me here!, can you explain what it was you wer
trying to get me to do?

Simo
 
Function CountByColor(InRange As Range, _
WhatColorIndex As Integer, _
Optional OfText As Boolean = False) As Long
'
' This function return the number of cells in InRange with
' a background color, or if OfText is True a font color,
' equal to WhatColorIndex.
'
Dim Rng As Range
Application.Volatile True

For Each Rng In InRange.Cells
if isdate(rng) then
If OfText = True Then
CountByColor = CountByColor - _
(Rng.Font.ColorIndex = WhatColorIndex)
Else
CountByColor = CountByColor - _
(Rng.Interior.ColorIndex = WhatColorIndex)
End If
End if
Next Rng

End Function
 
Sorry Peter you have lost me here!, can you explain what it was you were
trying to get me to do?

In your previous post you asked:
and in reply I suggested IsDate(ActiveCell)

But I can see now I misread your question, sorry!
I thought you wanted to check if the cell contain a valid date rather than
than if the cell contains today's date.

Regards,
Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top