Overflow Error 6

Ed Song

Board Regular
Joined
Sep 1, 2014
Messages
90
I'm not sure why I'm getting an overflow error 6 message, when all of my variables except a counter variable is declared as double variables. I thought variables declared as doubles can hold extraordinary large or small numbers and it should be nearly impossible to get an overflow error. Anyway the relevant sections of my code is as follows: (Note: (Module # ) is not part of the code).

(Module 1)

Option Explicit


Public Pop_Grp1 As Double 'Pop=Population, Grp=Group Public Pop_Grp2 As Double
Public Pop_Grp3 As Double
Public Pop_Grp4 As Double
Public Pop_Grp5 As Double
Public Pop_Grp6 As Double
Public PopTotal As Double

Public Y_Subs_Grp1 As Double
Public Y_Subs_Grp2 As Double
Public Y_Subs_Grp3 As Double
Public Y_Subs_Grp4 As Double
Public Y_Subs_Grp5 As Double
Public Y_Subs_Grp6 As Double

Public H_Subs_Grp1 As Double
Public H_Subs_Grp2 As Double
Public H_Subs_Grp3 As Double
Public H_Subs_Grp4 As Double
Public H_Subs_Grp5 As Double
Public H_Subs_Grp6 As Double

Public SubsShr_Grp1 As Double 'Subsidy division between the income groups
Public SubsShr_Grp2 As Double
Public SubsShr_Grp3 As Double
Public SubsShr_Grp4 As Double
Public SubsShr_Grp5 As Double
Public SubsShr_Grp6 As Double

Public Sub BringUpParameters()

(Lots of Code)

SubsShr_Grp1 = Sheets(1).Range("B51").Value
SubsShr_Grp2 = Sheets(1).Range("B52").Value
SubsShr_Grp3 = Sheets(1).Range("B53").Value
SubsShr_Grp4 = Sheets(1).Range("B54").Value
SubsShr_Grp5 = Sheets(1).Range("B55").Value
SubsShr_Grp6 = Sheets(1).Range("B56").Value

SubsShr_Y = Sheets(1).Range("B58").Value
SubsShr_IH = Sheets(1).Range("B59").Value


Y_Subs_Grp1 = Sheets(1).Range("D62").Value
Y_Subs_Grp2 = Sheets(1).Range("D63").Value
Y_Subs_Grp3 = Sheets(1).Range("D64").Value
Y_Subs_Grp4 = Sheets(1).Range("D65").Value
Y_Subs_Grp5 = Sheets(1).Range("D66").Value
Y_Subs_Grp6 = Sheets(1).Range("D67").Value

H_Subs_Grp1 = Sheets(1).Range("D62").Value
H_Subs_Grp2 = Sheets(1).Range("D63").Value
H_Subs_Grp3 = Sheets(1).Range("D64").Value
H_Subs_Grp4 = Sheets(1).Range("D65").Value
H_Subs_Grp5 = Sheets(1).Range("D66").Value
H_Subs_Grp6 = Sheets(1).Range("D67").Value

(More Code)


End Sub


(Module 9)

Option Explicit

Public PopGrp1 As Double
Public PopGrp2 As Double
Public PopGrp3 As Double
Public PopGrp4 As Double
Public PopGrp5 As Double
Public PopGrp6 As Double
Public Y_TotalRev As Double
Public K_TotalRev As Double
Public TotalRev As Double
Public Y_TotalSubs As Double
Public H_TotalSubs As Double



Public Sub AggregatesAndSubsidies()

Call BringUpParameters (Module 1)
Call IncomeEstimates
Call Group1Estimates
Call Group2Estimates
Call Group3Estimates
Call Group4Estimates
Call Group5Estimates
Call Group6Estimates (Module 8)

(Lots of Code)

'New Implied Family Income Subsidies or Benefits

Y_Subs_Grp1 = SubsShr_Grp1 * Y_TotalSubs / PopGrp1
Y_Subs_Grp2 = SubsShr_Grp2 * Y_TotalSubs / PopGrp2
Y_Subs_Grp3 = SubsShr_Grp3 * Y_TotalSubs / PopGrp3
Y_Subs_Grp4 = SubsShr_Grp4 * Y_TotalSubs / PopGrp4
Y_Subs_Grp5 = SubsShr_Grp5 * Y_TotalSubs / PopGrp5
Y_Subs_Grp6 = SubsShr_Grp6 * Y_TotalSubs / PopGrp6

'New Implied Family Human Capital Subsidies or Benefits

H_Subs_Grp1 = SubsShr_Grp1 * H_TotalSubs / PopGrp1
H_Subs_Grp2 = SubsShr_Grp2 * H_TotalSubs / PopGrp2
H_Subs_Grp3 = SubsShr_Grp3 * H_TotalSubs / PopGrp3
H_Subs_Grp4 = SubsShr_Grp4 * H_TotalSubs / PopGrp4
H_Subs_Grp5 = SubsShr_Grp5 * H_TotalSubs / PopGrp5
H_Subs_Grp6 = SubsShr_Grp6 * H_TotalSubs / PopGrp6



End Sub

The values of these variables are not that unusually large or small. Certainly within the range of 10^-10 to 10^10. The SubsShr_Grpi variables are between zero and one.

Anybody out there can help?
 
Last edited:

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
When the code breaks, what's the line that fails, and what are the values of numerator and denominator?
 
Upvote 0
The code breaks at: Y_Subs_Grp1 = SubsShr_Grp1 * Y_TotalSubs / PopGrp1

Y_TotalSubs is approximately 300,000, SubsShr_Grp1 is .25, popGrp1 is 1,000. If I take out that line, then of course the code breaks at the next line.

Actually, SubsShr_Grp1 is zero.
 
Last edited:
Upvote 0
Thanks, I discovered the problem. I forgot to put the underscore in the variable name. It should be read as pop_Grp1 instead of popGrp1. I declared both as doubles, but only assigned a value to pop_Grp1.
 
Upvote 0
Option Explicit would have caught that.
 
Upvote 0
No, Option Explicit is the first line of the modules. What happened is that I lost track of what I named my variables. I forgot that I had named a variable Pop_Grp1, and then assigned the same variable as PopGrp1. I assigned Pop_Grp1 to be 1,000 and did not assign PopGrp1 a value. Because I didn't assign PopGrp1 a value, the default assignment was zero.
 
Upvote 0

Forum statistics

Threads
1,215,039
Messages
6,122,802
Members
449,095
Latest member
m_smith_solihull

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top