This is due to how VBA evaluates math expressions. The return type of the expression will be the type of the first operand in the expression or its closest equivalent to a numeric type. However, the end result may not correspond to this type of return and throw overflow error.
When you make 500 * 100, the return type is integer. If you make 50,000 * 100, the return type of this expression is longer.
To avoid an overflow error, you can make an explicit cast so that it knows your intentions.
CLng(500) * 100
Pradeep Kumar Aug 04 '15 at 18:27 2015-08-04 18:27
source share