Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Old September 24th 04, 06:48 PM posted to microsoft.public.excel.programming
external usenet poster
 
First recorded activity by ExcelBanter: Jun 2004
Posts: 4
Default Summing Cells with a BLUE font (or any other color)

To all,

I am trying to sum cells that have a specific color.

Here is what I have so far:
Function SumByColor(InRange As Range, WhatColorIndex As Integer)

Dim Rng As Range
Dim OK As Boolean

Application.Volatile True
For Each Rng In InRange.Cells
OK = (Rng.Font.ColorIndex = WhatColorIndex)
If OK And IsNumeric(Rng.Value) Then
SumByColor = SumByColor + Rng.Value
End If
Next Rng

End Function
****Thank you Chip****

When I attempt to use this, I get an error "#NAME?"

Any ideas on what is going wrong?
Thanks.
--
RAYMOND KELLY

  #2   Report Post  
Old September 24th 04, 06:57 PM posted to microsoft.public.excel.programming
external usenet poster
 
First recorded activity by ExcelBanter: Jul 2006
Posts: 27,285
Default Summing Cells with a BLUE font (or any other color)

Put the code in a general module (in the vbe, insert=module). Not in a
module associated with a worksheet, thisworkbook, userform or a class
module.

--
Regards,
Tom Ogilvy

"RAYMOND KELLY" wrote in message
...
To all,

I am trying to sum cells that have a specific color.

Here is what I have so far:
Function SumByColor(InRange As Range, WhatColorIndex As Integer)

Dim Rng As Range
Dim OK As Boolean

Application.Volatile True
For Each Rng In InRange.Cells
OK = (Rng.Font.ColorIndex = WhatColorIndex)
If OK And IsNumeric(Rng.Value) Then
SumByColor = SumByColor + Rng.Value
End If
Next Rng

End Function
****Thank you Chip****

When I attempt to use this, I get an error "#NAME?"

Any ideas on what is going wrong?
Thanks.
--
RAYMOND KELLY


  #3   Report Post  
Old September 24th 04, 06:59 PM posted to microsoft.public.excel.programming
external usenet poster
 
First recorded activity by ExcelBanter: Jan 2004
Posts: 3,885
Default Summing Cells with a BLUE font (or any other color)

Hi
where do you put this function?. It has to go in a standard module

--
Regards
Frank Kabel
Frankfurt, Germany

"RAYMOND KELLY" schrieb im Newsbeitrag
...
To all,

I am trying to sum cells that have a specific color.

Here is what I have so far:
Function SumByColor(InRange As Range, WhatColorIndex As Integer)

Dim Rng As Range
Dim OK As Boolean

Application.Volatile True
For Each Rng In InRange.Cells
OK = (Rng.Font.ColorIndex = WhatColorIndex)
If OK And IsNumeric(Rng.Value) Then
SumByColor = SumByColor + Rng.Value
End If
Next Rng

End Function
****Thank you Chip****

When I attempt to use this, I get an error "#NAME?"

Any ideas on what is going wrong?
Thanks.
--
RAYMOND KELLY



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
How to replace the background color of all cells from light green to light blue? Claudia d'Amato Excel Discussion (Misc queries) 1 November 14th 08 08:09 PM
Summing Cells by Color Dtemp Excel Discussion (Misc queries) 5 July 2nd 08 03:35 PM
Cells won't change font color or show hi-lighted cells in document ROBIN Excel Discussion (Misc queries) 1 March 27th 08 10:39 PM
Setting of input cells as blue font and formula cells as black fon Sunnyskies Excel Discussion (Misc queries) 2 May 14th 07 05:27 PM
Color Cells Summing HANYANA Excel Worksheet Functions 29 January 10th 07 03:16 AM


All times are GMT +1. The time now is 11:19 PM.

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

About Us

"It's about Microsoft Excel"

 

Copyright © 2017