Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 1
Default Using function based on "Font Color"

Could you please inform me if there is a function which can count and/or
summarize cells in excel based on "Font Color"
  #2   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 2,420
Default Using function based on "Font Color"

Function CountCells(rng As Range, ci As Long)

For each cell in rng

If cell.Font.Colorindex = ci then

CountCells = CountCells +1
End If
Next cell
End Function

=CountCells(A1:B10,3)

--
__________________________________
HTH

Bob

"danai_mp" wrote in message
...
Could you please inform me if there is a function which can count and/or
summarize cells in excel based on "Font Color"



  #3   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 1
Default Using function based on "Font Color"

Thank you very much for your answer but unfortunately I am not so good in this
I need more help
If I have A1 = 7 (red colour), A2 =5 (green colour), A3 = 4 (lime colour),
A4 = 2 (green colour), A5 =6 (red colour), A6 =2 (red colour) etc
what can I use to have (a) the sum of red colour cells and (b) the count of
green colour cells?
thank you
--
Best regards
danai_mp


Ο χρήστης "Bob Phillips" *γγραψε:

Function CountCells(rng As Range, ci As Long)

For each cell in rng

If cell.Font.Colorindex = ci then

CountCells = CountCells +1
End If
Next cell
End Function

=CountCells(A1:B10,3)

--
__________________________________
HTH

Bob

"danai_mp" wrote in message
...
Could you please inform me if there is a function which can count and/or
summarize cells in excel based on "Font Color"




  #4   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 2,420
Default Using function based on "Font Color"

Here is a slightly different way.

Add this function

Function CellColours(rng As Range) As Variant
Dim ary As Variant
Dim cell As Range
Dim i As Long

ReDim ary(1 To rng.Rows.Count)
i = 1
For Each cell In rng

ary(i) = cell.Font.ColorIndex
i = i + 1
Next cell
CellColours = ary
End Function

and then sum like

=SUMPRODUCT(--(CellColours(A1:A10)=3) ,A1:A10)

and simply count like

=SUMPRODUCT(--(CellColours(A1:A10)=10))

--
__________________________________
HTH

Bob

"danai_mp" wrote in message
...
Thank you very much for your answer but unfortunately I am not so good in
this
I need more help
If I have A1 = 7 (red colour), A2 =5 (green colour), A3 = 4 (lime colour),
A4 = 2 (green colour), A5 =6 (red colour), A6 =2 (red colour) etc
what can I use to have (a) the sum of red colour cells and (b) the count
of
green colour cells?
thank you
--
Best regards
danai_mp


? ??????? "Bob Phillips" ???????:

Function CountCells(rng As Range, ci As Long)

For each cell in rng

If cell.Font.Colorindex = ci then

CountCells = CountCells +1
End If
Next cell
End Function

=CountCells(A1:B10,3)

--
__________________________________
HTH

Bob

"danai_mp" wrote in message
...
Could you please inform me if there is a function which can count
and/or
summarize cells in excel based on "Font Color"






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
Formatting "IF" response based on "OR" function veggies27 Excel Worksheet Functions 5 March 19th 08 07:12 PM
in excel, can I use values based on color for an "if, then" condi carlos Excel Worksheet Functions 1 August 31st 07 10:12 PM
Different Font Color for results evaluated by "IF" exceltyro New Users to Excel 2 April 9th 07 05:38 PM
Macro to concatenate into "B1" B2 thru B"x" based on new data in "Col A" Dennis Excel Discussion (Misc queries) 0 July 17th 06 02:38 PM
Any IF(A2=font color=red", "1", "0") in excel? Or a way to do it? Steve Excel Discussion (Misc queries) 1 November 7th 05 02:48 PM


All times are GMT +1. The time now is 03:20 AM.

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"