ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Counting by colour dilemma!! (https://www.excelbanter.com/excel-programming/316089-counting-colour-dilemma.html)

Simon Lloyd[_604_]

Counting by colour dilemma!!
 

Thanks Cripbd for your reply, i don't know whether that will work a
when i try to run my Auto_open i get a runtime error 13 type mismatc
in the Msgbox line where i have cccount it shows error 2015 when th
cursor is placed over it......any ideas?


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=27633


Dave Peterson[_4_]

Counting by colour dilemma!!
 
You won't want to refer to the activecell in your code that goes through a range
without selecting...

Function CountByColor(InRange As Range, WhatColorIndex As Integer, _
Optional OfText As Boolean = False) As Long
Dim Rng As Range
Application.Volatile True

For Each Rng In InRange.Cells
If IsError(Rng.Value) Then
'skip it
ElseIf 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


Simon Lloyd wrote:

Thanks Cripbd for your reply, i don't know whether that will work as
when i try to run my Auto_open i get a runtime error 13 type mismatch
in the Msgbox line where i have cccount it shows error 2015 when the
cursor is placed over it......any ideas?

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=276337


--

Dave Peterson



All times are GMT +1. The time now is 06:50 AM.

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