Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Where do I place this code and what else do I need to do for it to work?
Function SumIfByColor(InRange As Range, _ WhatColorIndex As Integer, SumRange As Range, _ Optional OfText As Boolean = False) As Variant ' ' This function will return the SUM of the values of cells in ' SumRange where the corresponding cell in InRange has a background ' color (or font color, if OfText is true) equal to WhatColorIndex. ' Dim OK As Boolean Dim Ndx As Long Application.Volatile True If (InRange.Rows.Count < SumRange.Rows.Count) Or _ (InRange.Columns.Count < SumRange.Columns.Count) Then SumIfByColor = CVErr(xlErrRef) Exit Function End If For Ndx = 1 To InRange.Cells.Count If OfText = True Then OK = (InRange.Cells(Ndx).Font.ColorIndex = WhatColorIndex) Else OK = (InRange.Cells(Ndx).Interior.ColorIndex = WhatColorIndex) End If If OK And IsNumeric(SumRange.Cells(Ndx).Value) Then SumIfByColor = SumIfByColor + SumRange.Cells(Ndx).Value End If Next Ndx End Function -- AOP |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I save new colour schemes for graphs in the colour template | Charts and Charting in Excel | |||
can the fill colour of a bar be tied to the data font colour data | Charts and Charting in Excel | |||
change a cell background colour to my own RGB colour requirements | Excel Discussion (Misc queries) | |||
SUMIF - Range name to used for the "sum_range" portion of a SUMIF function | Excel Worksheet Functions | |||
Text in Blue colour, but print in black colour | Excel Worksheet Functions |