View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Nick Hodge Nick Hodge is offline
external usenet poster
 
Posts: 1,173
Default Sum contents of comments based on back fill colour

Arron

Certainly it can be done, but you would need VBA code. The fill colour piece
would be fairly simple and the comment piece ok, providing the numbers are
on their own and not in random places around text. Below is an example UDF
that takes the range to be checked and a range (cell) with an example of the
background colour to test for. As I said this only works when the number is
the ONLY thing in the comment (This includes the default user name that
appears. obviously this could be coded out, but makes everything more
complicated

Function AddCommentsAndColours(rngToCheck As Range, chkColour As Range) As
Double
Dim mycell As Range
Dim colourNo As Integer
Dim dblFinal As Double
Application.Volatile True
colourNo = chkColour.Interior.ColorIndex
For Each mycell In rngToCheck
If mycell.Interior.ColorIndex = colourNo Then
If Not mycell.Comment Is Nothing Then
dblFinal = dblFinal + Val(mycell.Comment.Text)
End If
End If
Next mycell
AddCommentsAndColours = dblFinal
End Function

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
DTHIS
www.nickhodge.co.uk


"Arran" wrote in message
...
I have looked at C Pearsons and others stuff on Sumproduct background fill
colour But what I would like to do is Sum numbers contained in comments,
from
cells with a certain background colour. Can it be done, if so how?