Past Tip of the Day
Emily asks, "Please could you advise the formular solution for counting the number of cells that have a particular backgorund colour (i.e. these cells contain some data however the colour is what's important in order to count them).
"Logically I feel it should follow a standard formular i.e.
I believe the colour red should be identified by the number 3 (according the the help file)
I need to know how to code the background cell colour i.e. colorfill?, backgroundcolour?, interior.color?...???
Emily - if only it were that easy. You need to have a User Defined Function in VBA. Below is the code for the function. You need to enter this in a new code module in the workbook. If you are unfamiliar with VBA, read this page.
Once you have the code entered, you can use this formula:
Where D2 has the background format that you want to count.
Here is the code:
Function CountColor(Rng As Range, RngColor As Range) As Integer
Dim Cll As Range
Dim Clr As Long
Clr = RngColor.Range("A1").Interior.Color
For Each Cll In Rng
If Cll.Interior.Color = Clr Then
CountColor = CountColor + 1
By Bill Jelen on 17-Apr-2002
MrExcel.com Consulting can be hired to implement this concept, or many other cool applications, with your data.
MrExcel.com provides examples of Visual Basic procedures for illustration only, without warranty either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. The Visual Basic procedures on this web site are provided "as is" and we do not guarantee that they can be used in all situations.
Excel is a registered trademark
of the Microsoft® Corporation.
All contents Copyright
1998-2008 by MrExcel Consulting.