From: Otto Moehrbach on 3 Jun 2010 13:03 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
From: Don Guillett on 3 Jun 2010 13:19 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 dguillett(a)gmail.com "Otto Moehrbach" <moehrbachoextra(a)bellsouth.net> wrote in message news:eR29f6zALHA.4308(a)TK2MSFTNGP04.phx.gbl... > 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
From: Otto Moehrbach on 3 Jun 2010 14:19 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" <dguillett1(a)gmail.com> wrote in message news:#qf0vD0ALHA.3608(a)TK2MSFTNGP05.phx.gbl... > 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 > dguillett(a)gmail.com > "Otto Moehrbach" <moehrbachoextra(a)bellsouth.net> wrote in message > news:eR29f6zALHA.4308(a)TK2MSFTNGP04.phx.gbl... >> 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 >
From: FSt1 on 3 Jun 2010 14:29 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 > > . >
|
Pages: 1 Prev: "Unable to set the LineStyle property of the border class" Next: windows resize event trap |