Hello Everyone,
I am currently trying to run this code and it seems a little bit buggy.
It used to run before I close the my excel file but it is providing inaccurate computations specifically coming from (FRed, FGreen....etc.)
Now, when I try to re-run the file (after restarting my computer); I get Run-time error 6: overflow
I tried to google the problem and majority of them were suggesting to use larger data type. So far, what I tried are the following (Integer, Long & Double)
Here's my code as your reference
I am currently trying to run this code and it seems a little bit buggy.
It used to run before I close the my excel file but it is providing inaccurate computations specifically coming from (FRed, FGreen....etc.)
Now, when I try to re-run the file (after restarting my computer); I get Run-time error 6: overflow
I tried to google the problem and majority of them were suggesting to use larger data type. So far, what I tried are the following (Integer, Long & Double)
Here's my code as your reference
Code:
Dim wsDatabase, wsTracker As Worksheet
Set wsDatabase = Worksheets("Sheet2")
Set wsTracker = Worksheets("Sheet1")
Dim Red, Yellow, Green, Blue As Double
Dim FRed, FYellow, FGreen, FBlue, TotalPop, PopulationPerformance As Double
Red = Excel.Application.WorksheetFunction.CountIfs(wsDatabase.[C:C], wsTracker.Range("C5").Value, wsDatabase.[H:H], wsTracker.Range("C11").Value, wsDatabase.[N:N], "Red")
Yellow = Excel.Application.WorksheetFunction.CountIfs(wsDatabase.[C:C], wsTracker.Range("C5").Value, wsDatabase.[H:H], wsTracker.Range("C11").Value, wsDatabase.[N:N], "Yellow")
Green = Excel.Application.WorksheetFunction.CountIfs(wsDatabase.[C:C], wsTracker.Range("C5").Value, wsDatabase.[H:H], wsTracker.Range("C11").Value, wsDatabase.[N:N], "Green")
Blue = Excel.Application.WorksheetFunction.CountIfs(wsDatabase.[C:C], wsTracker.Range("C5").Value, wsDatabase.[H:H], wsTracker.Range("C11").Value, wsDatabase.[N:N], "Blue")
TotalPop = Red + Yellow + Green + Blue
FRed = (Red / TotalPop) * 0.09523
FYellow = (Yellow / TotalPop) * 0.238
FGreen = (Green / TotalPop) * 0.2857
FBlue = (Blue / TotalPop) * 0.3809
PopulationPerformance = FRed + FYellow + FGreen + FBlue
wsTracker.Range("F7").Value = FRed
wsTracker.Range("F8").Value = FYellow
wsTracker.Range("F9").Value = FGreen
wsTracker.Range("F10").Value = FBlue
wsTracker.Range("F11").Value = PopulationPerformance