#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default indeterminate 0/0


Is there a way to force VBA to do a division by zero without giving the
"divide by zero" error. I need a way to overrride this error but need
0/0 to equal 1


--
integreat
------------------------------------------------------------------------
integreat's Profile: http://www.excelforum.com/member.php...o&userid=34282
View this thread: http://www.excelforum.com/showthread...hreadid=566460

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default indeterminate 0/0

You can check the numerator and denominator to see if either/both are equal to
0.
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 380
Default indeterminate 0/0

Perhaps

Function DivideBy(denom, div)

If denom = 0 And div = 0 Then
DivideBy = 1
Else
DivideBy = denom / div
End If

End Function

MsgBox DivideBy(0,0)

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"integreat" wrote
in message ...

Is there a way to force VBA to do a division by zero without giving the
"divide by zero" error. I need a way to overrride this error but need
0/0 to equal 1


--
integreat
------------------------------------------------------------------------
integreat's Profile:

http://www.excelforum.com/member.php...o&userid=34282
View this thread: http://www.excelforum.com/showthread...hreadid=566460



  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,393
Default indeterminate 0/0

Just in case you really do want Visual Basic:

Function mydivider(a, b)
If b < 0 Then
temp = a / b
ElseIf a = 0 Then
temp = 1
End If
mydivider = temp
End Function


best wishes
--
Bernard V Liengme
www.stfx.ca/people/bliengme
remove caps from email

"integreat" wrote
in message ...

Is there a way to force VBA to do a division by zero without giving the
"divide by zero" error. I need a way to overrride this error but need
0/0 to equal 1


--
integreat
------------------------------------------------------------------------
integreat's Profile:
http://www.excelforum.com/member.php...o&userid=34282
View this thread: http://www.excelforum.com/showthread...hreadid=566460



  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 947
Default indeterminate 0/0

"divide by zero" error. I need a way to override this error but need
0/0 to equal 1


Hi. Just for discussion, 0/0 is an "Overflow" error.

Sub Demo()
Dim Ans
On Error Resume Next

'// 6 Overflow
Ans = 0 / 0
Debug.Print Err.Number; Err.Description

'// 11 Division by zero
Ans = 2 / 0
Debug.Print Err.Number; Err.Description

'// Maybe...
If Err.Number = 6 Then Ans = 1
Err.Clear
On Error GoTo 0
End Sub

(But you are correct, certain math programs treat 0/0 as Indeterminate vs
Excel's Overflow)
--
HTH. :)
Dana DeLouis
Windows XP, Office 2003


"integreat" wrote
in message ...

Is there a way to force VBA to do a division by zero without giving the
"divide by zero" error. I need a way to overrride this error but need
0/0 to equal 1


--
integreat
------------------------------------------------------------------------
integreat's Profile:
http://www.excelforum.com/member.php...o&userid=34282
View this thread: http://www.excelforum.com/showthread...hreadid=566460





  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default indeterminate 0/0

And that indeterminate makes sense, too.

numerator/demoninator = Quotient

which means that
numerator = Quotient * denominator

If the denominator is 0 and the numerator is non-zero, there are no non-zero
numerators that could make:
numerator = quotient * 0
correct.

If both the denominator and numerator = 0, then there are way too many correct
answers that make this:

0 = quotient * 0
(0 * any number = 0, so all numbers are correct)





Dana DeLouis wrote:

"divide by zero" error. I need a way to override this error but need
0/0 to equal 1


Hi. Just for discussion, 0/0 is an "Overflow" error.

Sub Demo()
Dim Ans
On Error Resume Next

'// 6 Overflow
Ans = 0 / 0
Debug.Print Err.Number; Err.Description

'// 11 Division by zero
Ans = 2 / 0
Debug.Print Err.Number; Err.Description

'// Maybe...
If Err.Number = 6 Then Ans = 1
Err.Clear
On Error GoTo 0
End Sub

(But you are correct, certain math programs treat 0/0 as Indeterminate vs
Excel's Overflow)
--
HTH. :)
Dana DeLouis
Windows XP, Office 2003

"integreat" wrote
in message ...

Is there a way to force VBA to do a division by zero without giving the
"divide by zero" error. I need a way to overrride this error but need
0/0 to equal 1


--
integreat
------------------------------------------------------------------------
integreat's Profile:
http://www.excelforum.com/member.php...o&userid=34282
View this thread: http://www.excelforum.com/showthread...hreadid=566460


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 947
Default indeterminate 0/0

Hi. Other arguments for "indeterminate" are with limits. If you take the
limit of x/x as x approaches 0, then the answer is 1.(2x/x is 2..etc)
The correct answer to what you want with 0/0 depends on what you are doing.
Hence...indeterminate. Interesting.
--
HTH. :)
Dana DeLouis
Windows XP, Office 2003


"Dave Peterson" wrote in message
...
And that indeterminate makes sense, too.

numerator/demoninator = Quotient

which means that
numerator = Quotient * denominator

If the denominator is 0 and the numerator is non-zero, there are no
non-zero
numerators that could make:
numerator = quotient * 0
correct.

If both the denominator and numerator = 0, then there are way too many
correct
answers that make this:

0 = quotient * 0
(0 * any number = 0, so all numbers are correct)





Dana DeLouis wrote:

"divide by zero" error. I need a way to override this error but need
0/0 to equal 1


Hi. Just for discussion, 0/0 is an "Overflow" error.

Sub Demo()
Dim Ans
On Error Resume Next

'// 6 Overflow
Ans = 0 / 0
Debug.Print Err.Number; Err.Description

'// 11 Division by zero
Ans = 2 / 0
Debug.Print Err.Number; Err.Description

'// Maybe...
If Err.Number = 6 Then Ans = 1
Err.Clear
On Error GoTo 0
End Sub

(But you are correct, certain math programs treat 0/0 as Indeterminate vs
Excel's Overflow)
--
HTH. :)
Dana DeLouis
Windows XP, Office 2003

"integreat"
wrote
in message ...

Is there a way to force VBA to do a division by zero without giving the
"divide by zero" error. I need a way to overrride this error but need
0/0 to equal 1


--
integreat
------------------------------------------------------------------------
integreat's Profile:
http://www.excelforum.com/member.php...o&userid=34282
View this thread:
http://www.excelforum.com/showthread...hreadid=566460


--

Dave Peterson



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 01:12 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"