Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / February 2007

Tip: Looking for answers? Try searching our database.

error in formula

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
marcus@hotmail.com - 20 Feb 2007 14:46 GMT
Hello everybody,
I'm having a problem with this formula:
=1/(1/b1+1/b2+1/b3+1/b4)
the problem is that sometimes I only enter two values, in cell b1 and
b2. Obviously that generates Div/0 error. How can I "tell" this
formula to calculate only cells that have something in it and ignore
empty ones.
Thanks for help,

Mark
ed@HelpExcel.com - 20 Feb 2007 14:58 GMT
Try this UDF

Public Function nums(ParamArray values())

   For i = 0 To UBound(values)
       If values(i) <> 0 Then
           newVal = newVal + 1 / values(i)
       End If
   Next

   nums = 1 / newVal

End Function

Regards,
Eddie
http://www.HelpExcel.com
ed@HelpExcel.com - 20 Feb 2007 15:03 GMT
I have copied the code to http://www.HelpExcel.com/examples.  The name
of the spreadsheet is customFunction.xls.
Bob Phillips - 20 Feb 2007 15:27 GMT
=1/SUM(IF(B1:B4<>"",1/B1:B4))

which is an array formula, so commit with Ctrl-Shift-Enter, not just Enter.

Signature

---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

> Hello everybody,
> I'm having a problem with this formula:
[quoted text clipped - 6 lines]
>
> Mark
marcus@hotmail.com - 20 Feb 2007 15:57 GMT
>=1/SUM(IF(B1:B4<>"",1/B1:B4))
>
>which is an array formula, so commit with Ctrl-Shift-Enter, not just Enter.

Thanks Bob, this works

Mark
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.