SUMIF by Text colour

TimS

New Member
Joined
Apr 16, 2002
Messages
3
Is it possible to SUMIF by text colour. Hurray if you can (and how do you do it?) Bah Humbug if you can't.
This message was edited by TimS on 2002-04-17 21:05
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Hi,

I have posted a UDF which is *not* working and a subroutine which is essentially identical and does work.

I have no idea why the UDF isn't working. Possibly others will have an answer, but this might get you started.

---------------------
Function SumColor(Rng As Range, textcolor As Integer)
Dim UsedCell As Range, MySum As Double

For Each UsedCell In Rng
If IsNumeric(UsedCell.Value) Then
If UsedCell.Font.ColorIndex = textcolor Then
MySum = MySum + UsedCell.Value
End If
End If
Next UsedCell

End Function

Sub Sumclr()
textcolor = 3
For Each Cell In Selection
If IsNumeric(Cell.Value) Then
If Cell.Font.ColorIndex = textcolor Then
MySum = MySum + Cell.Value
End If
End If
Next Cell
MsgBox MySum
End Sub
----------------------------

Regards,
Jay
 
Upvote 0
On 2002-04-17 21:24, Jay Petrulis wrote:
Hi,

I have posted a UDF which is *not* working and a subroutine which is essentially identical and does work.

I have no idea why the UDF isn't working. Possibly others will have an answer, but this might get you started.

---------------------
Function SumColor(Rng As Range, textcolor As Integer)
Dim UsedCell As Range, MySum As Double

For Each UsedCell In Rng
If IsNumeric(UsedCell.Value) Then
If UsedCell.Font.ColorIndex = textcolor Then
MySum = MySum + UsedCell.Value
End If
End If
Next UsedCell

End Function

Sub Sumclr()
textcolor = 3
For Each Cell In Selection
If IsNumeric(Cell.Value) Then
If Cell.Font.ColorIndex = textcolor Then
MySum = MySum + Cell.Value
End If
End If
Next Cell
MsgBox MySum
End Sub
----------------------------

Regards,
Jay

Jay the function needs to be finished off with

SumColor = MySum
 
Upvote 0
Hi Ivan,

DOH! Thanks for that. I think that is rule number one in creating UDFs, but somehow I missed it.

Thanks,
Jay
 
Upvote 0
my old pal Ivan never going to give you less that his best and thats whats here that missing bit.

but if you want some goodies i suggest another pal i chat and have a drink with over the email, Dave Hawley check ozgrid.com, there is a download and sorce code that does just this.

PLEASE can i request you post the detals here so all can see the wonderful work add your comments as well..

this will help...

PS if you miss a nights sleep once you surf Dave s site .. not my fault,,,
 
Upvote 0

Forum statistics

Threads
1,213,552
Messages
6,114,278
Members
448,559
Latest member
MrPJ_Harper

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top