Overflow error in a Loop Until statement of a VBA sub with a Do Loop

Anonymous
2025-02-20T17:24:30+00:00

Hi,

My VBA Sub produces an Overflow Error in the end-statement of a Do-loop: Loop Until Abs(M) < ZeroLimit,

where M and ZeroLimit both have a Dim statement As Double.

The value of ZeroLimit is set at 0.0001 (0.1 was also tested and gives same problem) and M can have any positive or negative value.

Within the Do-loop an InputBox requests to give a Value for M, and in case the value of M is Positive or Negative a different operation has to be performed.

Only in case the Abs Value of M is less than the ZeroLimit the loop has to be ended, in order to have a way out of the Loop.

A Screenshot which shows all Dim statements, the statement where ZeroLimit is assigned its value and theLoopUntil statement, including the Error Message is attached.

I tried a lot of things to eliminate that Overflow Error but did not yet find the correct solution.

As additional information:

My Excel version is installed with the Dutch language an with a comma as Decimal Separator, so I also tried to convert the values of M and ZeroLimit with CDbl, but that did not eliminate the Overflow Error either.

NB: In the InputBox, the value of M has to be written with a Comma. That is why I also tried the M=CDbl(M) statement

Can anybody give a good suggestion to overcome the Overflow Error?

Microsoft 365 and Office | Excel | For home | MacOS

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes