Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default VBA counting colors, errors

Sorry, people need Extra Sensory perception when i post. Module is as below:

Function CountCol(SumRange As Range, intColor As Integer) As Integer
Dim i As Integer
Dim Cell As Range

Set SumRange = SumRange.SpecialCells(xlCellTypeAllFormatCondition s)

For Each Cell In SumRange
If Cell.Interior.ColorIndex = intColor Then
i = i + 1
End If

Next Cell

CountCol = i

End Function


"Bob Phillips" wrote:

Which module?

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"TheRook" wrote in message
...
I am currently having 2 problems.
1. If an additional line in inserted with a specific color the count does
not automatically refresh. Can a loop be put in?

2. If I delete a row the function reports NAME#. Can something be added

to
the module to exclude deleted rows?

regards




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default VBA counting colors, errors

Changing a cell colour does not automatically trigger the calculate event,
so it will not fire your UDF. The best thing to do is to force a recalc by
ALt-F9 after changing a colour.

as to the second problem, this is what I wanted to see the code for, but I
am afraid I do not replicate the problem.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"TheRook" wrote in message
...
Sorry, people need Extra Sensory perception when i post. Module is as

below:

Function CountCol(SumRange As Range, intColor As Integer) As Integer
Dim i As Integer
Dim Cell As Range

Set SumRange = SumRange.SpecialCells(xlCellTypeAllFormatCondition s)

For Each Cell In SumRange
If Cell.Interior.ColorIndex = intColor Then
i = i + 1
End If

Next Cell

CountCol = i

End Function


"Bob Phillips" wrote:

Which module?

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"TheRook" wrote in message
...
I am currently having 2 problems.
1. If an additional line in inserted with a specific color the count

does
not automatically refresh. Can a loop be put in?

2. If I delete a row the function reports NAME#. Can something be

added
to
the module to exclude deleted rows?

regards






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Counting errors kittronald Excel Worksheet Functions 5 May 19th 11 11:45 PM
Counting the number of errors in a worksheet Bob Excel Worksheet Functions 7 November 8th 07 10:22 AM
Counting with a condition disregarding errors vsoler Excel Worksheet Functions 7 May 19th 07 10:04 PM
Counting Errors Tarique Excel Worksheet Functions 1 February 24th 06 04:54 PM
Counting colors reno Excel Discussion (Misc queries) 1 October 3rd 05 10:44 PM


All times are GMT +1. The time now is 04:42 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"