Sum cells in excel if shaded

D

David Billigmeier

You will need a UDF, the following will sum every cell if it has ANY color
shading (will ignore only the cells with no shading). Then, to implement,
use the following in any cell on your spreadsheet =SumHighlighted(A1:D100)...
change reference to fit your data.

Function SumHighlighted(rng As Range)
For Each rng In rng
If Not (rng.Interior.ColorIndex = xlNone) Then
Sum = Sum + rng
End If
Next
SumHighlighted = Sum
End Function
 
L

L. Howard Kittle

Hi David,

If the highlighting is from selecting the cells, then the sheet will sum
them in the bottom right side of the worksheet. Right click in the bottom
margin below any tool bars you have at the bottom and select SUM. Select
the cells and see Sum=nnn.

HTH
Regards,
Howard
 
Top