Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Macro erro
Hi
I have the following subprocedure Per=(our20/total20) Some times the variables our20 and total20 will be =0. In these situations, I am getting the message "Run-time error'6' overflow" . The subprocedure above is highlighted. I believe it is because the division is 0/0. Could anyone help me to solve this problem? Thanks, Orquidea |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Macro erro
hi
you could wrap it in an if statement to test for zero. if our20/total20< 0 then per=(our20/total20) end if or.... if our20/total20= 0 then do something else else per=(our20/total20) end if my thoughts Regards FSt1 "orquidea" wrote: Hi I have the following subprocedure Per=(our20/total20) Some times the variables our20 and total20 will be =0. In these situations, I am getting the message "Run-time error'6' overflow" . The subprocedure above is highlighted. I believe it is because the division is 0/0. Could anyone help me to solve this problem? Thanks, Orquidea |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Macro erro
Thanks a lot for your help. It worked.
Orquidea "FSt1" wrote: hi you could wrap it in an if statement to test for zero. if our20/total20< 0 then per=(our20/total20) end if or.... if our20/total20= 0 then do something else else per=(our20/total20) end if my thoughts Regards FSt1 "orquidea" wrote: Hi I have the following subprocedure Per=(our20/total20) Some times the variables our20 and total20 will be =0. In these situations, I am getting the message "Run-time error'6' overflow" . The subprocedure above is highlighted. I believe it is because the division is 0/0. Could anyone help me to solve this problem? Thanks, Orquidea |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
Macro erro
glad to help
regards FSt1 "orquidea" wrote: Thanks a lot for your help. It worked. Orquidea "FSt1" wrote: hi you could wrap it in an if statement to test for zero. if our20/total20< 0 then per=(our20/total20) end if or.... if our20/total20= 0 then do something else else per=(our20/total20) end if my thoughts Regards FSt1 "orquidea" wrote: Hi I have the following subprocedure Per=(our20/total20) Some times the variables our20 and total20 will be =0. In these situations, I am getting the message "Run-time error'6' overflow" . The subprocedure above is highlighted. I believe it is because the division is 0/0. Could anyone help me to solve this problem? Thanks, Orquidea |
#5
Posted to microsoft.public.excel.misc
|
|||
|
|||
Macro erro
I have the following subprocedure
Per=(our20/total20) Some times the variables our20 and total20 will be =0. In these situations, I am getting the message "Run-time error'6' overflow" . The subprocedure above is highlighted. I believe it is because the division is 0/0. Zero divided by any number (except zero) equals zero, so the numerator being zero is not the problem. On the other hand, any number divided by zero is (in imprecise mathematical terms) infinity, which is not a number; so, VB returns an error for division by zero. The special case of zero divided by zero is undefined, not infinity... the reason (again, in imprecise mathematical terms) has to do with the previous two statements... any number divided by zero is infinity but zero divided by any number is zero... there is no way to decide which of these holds for a result, zero or infinity, so the division of zero by zero is undefined. Anyway, the way to handle your problem is to test the denominator for zero... If total20 = 0 Then ' ' Handle your error here. There are lots of ways to do this, but they ' all depend on how you want your program to proceed for this case ' Else Per = our20 / total 20 End If Rick |
#6
Posted to microsoft.public.excel.misc
|
|||
|
|||
Macro erro
It worked??? Are you sure?
Testing our20/total20 in an If statement will generate an error if total20 is equal to 0. Rick "orquidea" wrote in message ... Thanks a lot for your help. It worked. Orquidea "FSt1" wrote: hi you could wrap it in an if statement to test for zero. if our20/total20< 0 then per=(our20/total20) end if or.... if our20/total20= 0 then do something else else per=(our20/total20) end if my thoughts Regards FSt1 "orquidea" wrote: Hi I have the following subprocedure Per=(our20/total20) Some times the variables our20 and total20 will be =0. In these situations, I am getting the message "Run-time error'6' overflow" . The subprocedure above is highlighted. I believe it is because the division is 0/0. Could anyone help me to solve this problem? Thanks, Orquidea |
#7
Posted to microsoft.public.excel.misc
|
|||
|
|||
Macro erro
Here is how I rewrote the procedure based on FSt1's answer.
If Total20 < 0 Then per = (our20 / total20) End If I tested this and worked. I know when divisions are done in spreadsheet where a number is divided by Zero, the message "#DIV/0!" pops up. Therefore I assumed that the error I got with FSt1's answer was because of that. That's why I rewrote the procedure above. Thanks for your explanation. It helps me to understand better how macros should be set. Orquidea "Rick Rothstein (MVP - VB)" wrote: I have the following subprocedure Per=(our20/total20) Some times the variables our20 and total20 will be =0. In these situations, I am getting the message "Run-time error'6' overflow" . The subprocedure above is highlighted. I believe it is because the division is 0/0. Zero divided by any number (except zero) equals zero, so the numerator being zero is not the problem. On the other hand, any number divided by zero is (in imprecise mathematical terms) infinity, which is not a number; so, VB returns an error for division by zero. The special case of zero divided by zero is undefined, not infinity... the reason (again, in imprecise mathematical terms) has to do with the previous two statements... any number divided by zero is infinity but zero divided by any number is zero... there is no way to decide which of these holds for a result, zero or infinity, so the division of zero by zero is undefined. Anyway, the way to handle your problem is to test the denominator for zero... If total20 = 0 Then ' ' Handle your error here. There are lots of ways to do this, but they ' all depend on how you want your program to proceed for this case ' Else Per = our20 / total 20 End If Rick |
#8
Posted to microsoft.public.excel.misc
|
|||
|
|||
Macro erro
yes.
I answered to quick on this one. what popped in my mind was "test for zero" and i didn't think about what i wrote enought. I would have caught if i have tested but i didn't test which i usually do. sorry for the miss lead. regards FSt1 "orquidea" wrote: Here is how I rewrote the procedure based on FSt1's answer. If Total20 < 0 Then per = (our20 / total20) End If I tested this and worked. I know when divisions are done in spreadsheet where a number is divided by Zero, the message "#DIV/0!" pops up. Therefore I assumed that the error I got with FSt1's answer was because of that. That's why I rewrote the procedure above. Thanks for your explanation. It helps me to understand better how macros should be set. Orquidea "Rick Rothstein (MVP - VB)" wrote: I have the following subprocedure Per=(our20/total20) Some times the variables our20 and total20 will be =0. In these situations, I am getting the message "Run-time error'6' overflow" . The subprocedure above is highlighted. I believe it is because the division is 0/0. Zero divided by any number (except zero) equals zero, so the numerator being zero is not the problem. On the other hand, any number divided by zero is (in imprecise mathematical terms) infinity, which is not a number; so, VB returns an error for division by zero. The special case of zero divided by zero is undefined, not infinity... the reason (again, in imprecise mathematical terms) has to do with the previous two statements... any number divided by zero is infinity but zero divided by any number is zero... there is no way to decide which of these holds for a result, zero or infinity, so the division of zero by zero is undefined. Anyway, the way to handle your problem is to test the denominator for zero... If total20 = 0 Then ' ' Handle your error here. There are lots of ways to do this, but they ' all depend on how you want your program to proceed for this case ' Else Per = our20 / total 20 End If Rick |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how to add erro bars for each bar, rather than the whle series | Charts and Charting in Excel | |||
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort | Excel Worksheet Functions | |||
Excel Erro | Setting up and Configuration of Excel | |||
Erro in Formula, Pleas Help? | Excel Worksheet Functions | |||
Macro needed to Paste Values and prevent Macro operation | Excel Discussion (Misc queries) |