Sum cells in excel if shaded

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I conditionally sum a set of cells if I have them highlighted?
 
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top