ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   counting by colour only if a cell contains a date??? (https://www.excelbanter.com/excel-programming/315203-counting-colour-only-if-cell-contains-date.html)

Simon Lloyd[_598_]

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

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

Simo

--
Simon Lloy
-----------------------------------------------------------------------
Simon Lloyd's Profile: http://www.excelforum.com/member.php...nfo&userid=670
View this thread: http://www.excelforum.com/showthread.php?threadid=27311


Tom Ogilvy

counting by colour only if a cell contains a date???
 
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

--
Regards,
Tom Ogilvy



"Simon Lloyd" wrote in message
...

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

Simon


--
Simon Lloyd
------------------------------------------------------------------------
Simon Lloyd's Profile:

http://www.excelforum.com/member.php...fo&userid=6708
View this thread: http://www.excelforum.com/showthread...hreadid=273115




Peter T

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

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:
i am unsure how to add a line to the code
that will follow the criteria if activecell.value = Date then count


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




All times are GMT +1. The time now is 10:01 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com