Hello,
I have a VBA sub that reads some values off a worksheet, calculates some statistics and prints them into different cells. I built the workbook using Excel 2011 for Mac.
At one point I am getting a runtime 11 error: "Division by zero". The line highlighted by the debugger only uses WorksheetFunction.Sum, so I am mystified.
The actual sum is less than 300, and when I use the Immediate window the same line of code works just fine. When I use the Debugger to "Step Into" there is also no problem, and I can step all the way to the end of the program with no more errors.
The same code (with same inputs) runs without throwing an error when I tested it on Excel 2007 on Windows XP.
What could be causing this?
-Amy Galick
I have a VBA sub that reads some values off a worksheet, calculates some statistics and prints them into different cells. I built the workbook using Excel 2011 for Mac.
At one point I am getting a runtime 11 error: "Division by zero". The line highlighted by the debugger only uses WorksheetFunction.Sum, so I am mystified.
Code:
Dim temp As Double
With Application.WorksheetFunction
'The dynamic array prereq1 had a few values assigned earlier; it's Dimmed as Double
temp = .Sum(prereq1) '******division by zero here
End With
The actual sum is less than 300, and when I use the Immediate window the same line of code works just fine. When I use the Debugger to "Step Into" there is also no problem, and I can step all the way to the end of the program with no more errors.
The same code (with same inputs) runs without throwing an error when I tested it on Excel 2007 on Windows XP.
What could be causing this?
-Amy Galick