![]() |
FindNext problem
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 |
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 |
FindNext problem
tom, (i'm scratching my head)
i've got XL2002, and am using it in a VBA, maybe i ought to try re-entering the whole procedure? "Tom Ogilvy" wrote in message ... 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 |
FindNext problem
First I would get it working outside using it in the spread sheet, then if
it doesn't work in the spreadsheet you will have to find another way. My statement that is works in UDF's in versions later than xl2000 is base on what Dave Peterson has stated in this group. I don't have first hand knowledge that it does, but I know it doesn't in XL2000 and earlier. -- Regards, Tom Ogilvy "mark kubicki" wrote in message ... tom, (i'm scratching my head) i've got XL2002, and am using it in a VBA, maybe i ought to try re-entering the whole procedure? "Tom Ogilvy" wrote in message ... 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 |
All times are GMT +1. The time now is 02:16 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com