# Overflow 6 in code - why, and how to solve?

• Dear everyone. I have coded the following, but I cannot get it to run...I get the errormessage "runtime error 6: overflow". Can anyone help me figure out how to make it work. This is my code:

Best regards,

Maria Wieborg

• Re: Overflow 6 in code - why, and how to solve?

Hi Maria,

Welcome to the forum.

Please remember to use code tags when posting code - I've added them for you this time.

• Re: Overflow 6 in code - why, and how to solve?

Oh, thanks

• Re: Overflow 6 in code - why, and how to solve?

... I think the error is in my function y, because when I try debugging, the overflow statement is in this function, but I still cannot see what is wrong? If anyone could please help me

• Re: Overflow 6 in code - why, and how to solve?

Code
``````For i = 0 To 20
T = Cells(5, i + 3).Value
y1 = y(Phi, Kr, Ke, Br, Be, Rho, rr, e1, T)
Cells(6 + j, i + 3) = y1
Next``````

If Cells(5,i+3) contains a very small number, the divison in y1 by Tau (T) might cause an overflow error.
It would probably occur if T = 0, but is read as a very small number.

• Re: Overflow 6 in code - why, and how to solve?

I see your point.. If I add a small value to T the code runs, but then I have constant values - and seems wrong too ... hmm.. But thank you

• Re: Overflow 6 in code - why, and how to solve?

Just add some code at the beginning of the functions to test if Tau = 0. You might also want to write code to test if other arguments can lead to division by (near) zero.

## Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!