Okay, people. Can someone see an error in this UDF code??? I'm coming
up with a "#VALUE!" error.
Public Function findfuel(rng As Range)
Dim rCell As Range
Dim mytotal As Double
Dim numberofcells As Integer
Dim myaverage As Double
Const sStr As String = "fuel"
For Each rCell In rng
If InStr(1, rCell.Comment.Text, sStr, vbTextCompare) Then
mytotal = mytotal + rCell.Value
numberofcells = numberofcells + 1
myaverage = mytotal / numberofcells
End If
Next rCell
findfuel = average
End Function
Seems pretty straightforward.
Any help would be appreciated. Thanks.
Bookmarks