I have encountered this error even though all my data types seems fine.
Run-time error 6 Overflow
Here is the function:
Function equation(x As Long) As Long
Dim a As Long, b As Double
a = Int(((x - 2) Mod 8) / 6) + 2 * Int((x - 2) / 8)
b = (x + a - 1) / 2
equation = Abs(4 * b + 5 + 2 * Int(b))
End Function
Error is encountered when x = 572662307 it says overflow.
Intfunction? It performs integer-truncation.572662307is one-quarter towards the max value of a 32-bit signed integer (2 billion). In VBALongis a 32-bit integer and is not a 64-bit integer as in C#. I recommend changingxtoDouble.LongLongis not available in 32-bit Office.