ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   OverFlow (https://www.excelbanter.com/excel-programming/443064-overflow.html)

Otto Moehrbach[_2_]

OverFlow
 
Excel 2007, Win 7
I have the following line of code wherein I want to average the occupied
cells in TheRng, and ignore the blank cells:
Cells(1,2) = Application.Sum(TheRng) / Application.CountA(TheRng)
I get an error with the single word "Overflow".
What does that error message mean? Thanks for your time. Otto


Don Guillett[_2_]

OverFlow
 
As ALWAYS, post YOUR code for comments. Could be a dim problem
And, what's wrong with cells(1,2)=application.average(therng)
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Otto Moehrbach" wrote in message
...
Excel 2007, Win 7
I have the following line of code wherein I want to average the occupied
cells in TheRng, and ignore the blank cells:
Cells(1,2) = Application.Sum(TheRng) / Application.CountA(TheRng)
I get an error with the single word "Overflow".
What does that error message mean? Thanks for your time. Otto



Otto Moehrbach[_2_]

OverFlow
 
Thanks Don. The problem I thought I had was that the user might place a
zero in a cell or leave it blank without giving it a thought. AVERAGE
ignores the blank cells and doesn't ignore the cells that contain zeros. I
got with the OP to clarify what he wants and, to my chagrin, he wants the
cells summed and then divided by the count of the cells. My code would then
be:
Application.Sum(TheRng)/TheRng.Count
I did that and I got no error.
Thanks again. Otto

"Don Guillett" wrote in message
...
As ALWAYS, post YOUR code for comments. Could be a dim problem
And, what's wrong with cells(1,2)=application.average(therng)
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Otto Moehrbach" wrote in message
...
Excel 2007, Win 7
I have the following line of code wherein I want to average the occupied
cells in TheRng, and ignore the blank cells:
Cells(1,2) = Application.Sum(TheRng) / Application.CountA(TheRng)
I get an error with the single word "Overflow".
What does that error message mean? Thanks for your time. Otto



FSt1

OverFlow
 
hi
could mean that you have TheRng dimed as a integer and your average is
producing decimals. could be as simple as rediming to a double. but as Don
pointed out...without seeing your code (and sometimes data), we are only
guessing.

regards
FSt1

"Otto Moehrbach" wrote:

Excel 2007, Win 7
I have the following line of code wherein I want to average the occupied
cells in TheRng, and ignore the blank cells:
Cells(1,2) = Application.Sum(TheRng) / Application.CountA(TheRng)
I get an error with the single word "Overflow".
What does that error message mean? Thanks for your time. Otto

.



All times are GMT +1. The time now is 09:55 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com