FindNext problem
If you are using a version of Excel prior to xl2002, then Find does not work
in a function used in a worksheet.
Other than that, your code looks ok. Have you tried calling the Function
from a VBA module and see if it works that way? I suspect it does.
--
Regards,
Tom Ogilvy
"mark kubicki" wrote in message
...
this should be simple, but my FindNext line is causing an error; any
suggestions?
on the wroksheets("Sheet1") is entered:
TotalHousemateUtility(A1); the value of A1 is a string
Public Function TotalHousemateUtility(Name)
Dim firstAddress
Dim c As Range
Dim subTotal as Single
subTotal = 0
With Worksheets("Sheet 2").Range("B3:B10")
Set c = .Find(Name, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
subTotal = subTotal + Worksheets("Tally
Sheet").Range(c.Address).Offset(0, 2).Value
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With
TotalHousemateUtility = subTotal
End Function
|