I am totally confused here. I was well into a project and assigned a value of 14464 * 5 to a variable and got the run-time error 6 - Overflow. Hmm, oh yes, I dimensioned my variable as an Integer. No problems. Changed to a Long. Saved, re-ran the code. Error 6 again, overflow. Sorry, but this is getting stupid. The results of the above calculation is 72320. Well a Long variable has an upper range exceeding 2.147 million so as nuts as this sounds, this does not compute. At this point I was starting to get angry.
So I ran the following code in a new Workbook in a new subroutine.
Dim calcRez as Single
calcRez = 14464 * 1
Msgbox calcRez
Ran it, there was no problem as the result is 14464. Incremented the calculation by one to 14464 * 2. Again no problem because that result is 28928. Increment the calculation by one to 14464 * 3. Overflow error. What the <bleep>? The result of that calculation is 43992 and it is waaaaaaaaaaaaay under the billions in the upper bounds of the Single dimensioned variable. In fact, my original calculation of 14464 * 5 should have worked with a variable dimensioned as Long.
I am now beyond angry. What am I missing here? Is this a bug in VBA? If so, I am amazed I have never encountered it before. True, I have mainly been using Integers for numbers. Do you have to dimension a Long and a Single in different manner?
I did a search on that run-time error in the forum, but most people had improperly dimensioned or forgotten to declare their variables. Not so with me once I corrected for the Integer variable mistake.
So I ran the following code in a new Workbook in a new subroutine.
Dim calcRez as Single
calcRez = 14464 * 1
Msgbox calcRez
Ran it, there was no problem as the result is 14464. Incremented the calculation by one to 14464 * 2. Again no problem because that result is 28928. Increment the calculation by one to 14464 * 3. Overflow error. What the <bleep>? The result of that calculation is 43992 and it is waaaaaaaaaaaaay under the billions in the upper bounds of the Single dimensioned variable. In fact, my original calculation of 14464 * 5 should have worked with a variable dimensioned as Long.
I am now beyond angry. What am I missing here? Is this a bug in VBA? If so, I am amazed I have never encountered it before. True, I have mainly been using Integers for numbers. Do you have to dimension a Long and a Single in different manner?
I did a search on that run-time error in the forum, but most people had improperly dimensioned or forgotten to declare their variables. Not so with me once I corrected for the Integer variable mistake.