Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 410
Default Average numbers by fill color

I still need an answer to Average cells that have the same fill
color. But only use the cells that have numbers in them. Some may
contain words. They are mostly blank. Here is my code so far.

Thanks,
Jay
Function AVGColor(rColor As Range, Range As Range)
Dim rCell
Dim iCol As Integer
Dim C As Range
Dim vResult As Double

iCol = rColor.Interior.ColorIndex
For Each rCell In Range
If rCell.Interior.ColorIndex = iCol Then
vResult = WorksheetFunction.Sum(rCell, vResult)
End If
Next rCell

For Each C In Range

If C.Interior.ColorIndex = rColor.Interior.ColorIndex Then
Count = Count + 1

End If
Next C

If AVGColor = vResult / Count = Numeric Then
AVGColor = vResult / Count
Else: AVGColor = ""
End If

End Function

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default Average numbers by fill color

I answered that 2 hours ago in the other thread.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"jlclyde" wrote in message
oups.com...
I still need an answer to Average cells that have the same fill
color. But only use the cells that have numbers in them. Some may
contain words. They are mostly blank. Here is my code so far.

Thanks,
Jay
Function AVGColor(rColor As Range, Range As Range)
Dim rCell
Dim iCol As Integer
Dim C As Range
Dim vResult As Double

iCol = rColor.Interior.ColorIndex
For Each rCell In Range
If rCell.Interior.ColorIndex = iCol Then
vResult = WorksheetFunction.Sum(rCell, vResult)
End If
Next rCell

For Each C In Range

If C.Interior.ColorIndex = rColor.Interior.ColorIndex Then
Count = Count + 1

End If
Next C

If AVGColor = vResult / Count = Numeric Then
AVGColor = vResult / Count
Else: AVGColor = ""
End If

End Function



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 410
Default Average numbers by fill color

On Aug 30, 3:56 pm, "Bob Phillips" wrote:
I answered that 2 hours ago in the other thread.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"jlclyde" wrote in message

oups.com...



I still need an answer to Average cells that have the same fill
color. But only use the cells that have numbers in them. Some may
contain words. They are mostly blank. Here is my code so far.


Thanks,
Jay
Function AVGColor(rColor As Range, Range As Range)
Dim rCell
Dim iCol As Integer
Dim C As Range
Dim vResult As Double


iCol = rColor.Interior.ColorIndex
For Each rCell In Range
If rCell.Interior.ColorIndex = iCol Then
vResult = WorksheetFunction.Sum(rCell, vResult)
End If
Next rCell


For Each C In Range


If C.Interior.ColorIndex = rColor.Interior.ColorIndex Then
Count = Count + 1


End If
Next C


If AVGColor = vResult / Count = Numeric Then
AVGColor = vResult / Count
Else: AVGColor = ""
End If


End Function- Hide quoted text -


- Show quoted text -


THe answer that you gave put out the same results that i was getting.
Your code counted blank cells as did mine. I want to skip cells that
do nto ahve numbers in them. For example I have 6 cells with color
and 3 of them have the number one in them. the average shoudl be 1
and it says .50.
Jay

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,268
Default Average numbers by fill color

When you are in a thread always post to the same thread. Don't start new
threads with the same question

http://www.cpearson.com/excel/newposte.htm


--
Regards,

Peo Sjoblom


THe answer that you gave put out the same results that i was getting.
Your code counted blank cells as did mine. I want to skip cells that
do nto ahve numbers in them. For example I have 6 cells with color
and 3 of them have the number one in them. the average shoudl be 1
and it says .50.
Jay



  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default Average numbers by fill color

No, I responded to that comment, which you would have seen if you stuck to
the same thread.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"jlclyde" wrote in message
ps.com...
On Aug 30, 3:56 pm, "Bob Phillips" wrote:
I answered that 2 hours ago in the other thread.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

"jlclyde" wrote in message

oups.com...



I still need an answer to Average cells that have the same fill
color. But only use the cells that have numbers in them. Some may
contain words. They are mostly blank. Here is my code so far.


Thanks,
Jay
Function AVGColor(rColor As Range, Range As Range)
Dim rCell
Dim iCol As Integer
Dim C As Range
Dim vResult As Double


iCol = rColor.Interior.ColorIndex
For Each rCell In Range
If rCell.Interior.ColorIndex = iCol Then
vResult = WorksheetFunction.Sum(rCell, vResult)
End If
Next rCell


For Each C In Range


If C.Interior.ColorIndex = rColor.Interior.ColorIndex Then
Count = Count + 1


End If
Next C


If AVGColor = vResult / Count = Numeric Then
AVGColor = vResult / Count
Else: AVGColor = ""
End If


End Function- Hide quoted text -


- Show quoted text -


THe answer that you gave put out the same results that i was getting.
Your code counted blank cells as did mine. I want to skip cells that
do nto ahve numbers in them. For example I have 6 cells with color
and 3 of them have the number one in them. the average shoudl be 1
and it says .50.
Jay





  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 410
Default Average numbers by fill color

On Aug 30, 6:04 pm, "Bob Phillips" wrote:
No, I responded to that comment, which you would have seen if you stuck to
the same thread.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"jlclyde" wrote in message

ps.com...



On Aug 30, 3:56 pm, "Bob Phillips" wrote:
I answered that 2 hours ago in the other thread.


--
---
HTH


Bob


(there's no email, no snail mail, but somewhere should be gmail in my
addy)


"jlclyde" wrote in message


groups.com...


I still need an answer to Average cells that have the same fill
color. But only use the cells that have numbers in them. Some may
contain words. They are mostly blank. Here is my code so far.


Thanks,
Jay
Function AVGColor(rColor As Range, Range As Range)
Dim rCell
Dim iCol As Integer
Dim C As Range
Dim vResult As Double


iCol = rColor.Interior.ColorIndex
For Each rCell In Range
If rCell.Interior.ColorIndex = iCol Then
vResult = WorksheetFunction.Sum(rCell, vResult)
End If
Next rCell


For Each C In Range


If C.Interior.ColorIndex = rColor.Interior.ColorIndex Then
Count = Count + 1


End If
Next C


If AVGColor = vResult / Count = Numeric Then
AVGColor = vResult / Count
Else: AVGColor = ""
End If


End Function- Hide quoted text -


- Show quoted text -


THe answer that you gave put out the same results that i was getting.
Your code counted blank cells as did mine. I want to skip cells that
do nto ahve numbers in them. For example I have 6 cells with color
and 3 of them have the number one in them. the average shoudl be 1
and it says .50.
Jay- Hide quoted text -


- Show quoted text -


Bob,
This is what the code shoudl read. Thank you for pointing me in the
right direction.
Jay
If C.Interior.ColorIndex = iCol And IsNumeric(C.Value) And Not
IsEmpty(C.Value) Then

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
trouble with viewing fill color and font color CMinard Excel Worksheet Functions 3 May 12th 06 09:09 PM
Sort or sub-total by Fill color or font color Excel_seek_help Excel Discussion (Misc queries) 1 April 27th 06 09:01 PM
My fill color and font color do not work in Excel Std Edition 2003 chapstick Excel Discussion (Misc queries) 1 September 11th 05 08:48 PM
Excel 2003 will not display color fonts or color fill cells DaveC Excel Worksheet Functions 1 April 11th 05 04:38 PM
My excel 2003 wont let me fill cells with color or color the tabs. trizog New Users to Excel 2 February 22nd 05 06:43 PM


All times are GMT +1. The time now is 08:11 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"