LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 169
Default Counting cells with a specific range

This function is taken from C Pearsons site and it counts the number of cells
within
a range. Can someone explain the asterixxed lines below
Thanks

#CountByColor = CountByColor - _
# (Rng.Font.ColorIndex = WhatColorIndex)
#Else
# CountByColor = CountByColor - _
# (Rng.Interior.ColorIndex = WhatColorIndex)



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 OfText = True Then
CountByColor = CountByColor - _
(Rng.Font.ColorIndex = WhatColorIndex)
Else
CountByColor = CountByColor - _
(Rng.Interior.ColorIndex = WhatColorIndex)
End If
Next Rng

End Function


 
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 the occurrence of specific text within a date range John Excel Worksheet Functions 4 May 20th 10 09:32 PM
Counting items with a specific quanitifier in a date range sprillaman Excel Worksheet Functions 3 December 9th 08 08:25 PM
Counting Specific Character(s) In A Range? FARAZ QURESHI Excel Discussion (Misc queries) 10 September 14th 07 04:32 AM
Counting a specific range of values within a column kenm Excel Discussion (Misc queries) 7 January 2nd 07 08:34 PM
counting cells in a data range that meet 3 specific conditions bekah7 Excel Discussion (Misc queries) 3 October 1st 05 06:21 AM


All times are GMT +1. The time now is 07:40 PM.

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

About Us

"It's about Microsoft Excel"