View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
NewToVB NewToVB is offline
external usenet poster
 
Posts: 48
Default Range.Average Problem

If I have it formatted like this:
LCV.Range("C2:C11").NumberFormat = "0.000"

can it return negative numbers? because some of the numbers its averaging
are negative?? Thanks in advance!

"NewToVB" wrote:

Thanks for the comments. LCV is my excel worksheet, I'm using Visual Studio
(Visual Basic) rather than VBA. I have to have LCV in front to tell it which
sheet. I have LCV.Range in several other places in my code and it works
fine, but I think I must be coding the Average Function wrong. You can
average a range right? I don't know why I'd be getting all zeros.

"Tom Ogilvy" wrote:

I don't know what LCV is a reference to, but I suspect

LCV.Range doesn't point where you think it does

or

LCV.Range is blank

or

LCV.Range

doesn't contain any numbers (or contains numbers that are stored as text
strings).

if you try using Average in a cell going against the range you want averaged
and get a valid answer, then you can disregard the stored as strings.

--
Regards,
Tom Ogilvy

"NewToVB" wrote:

I'm trying to average I3:I & c + 2
but I keep getting zeros. Any ideas why?

CSVCICAvg = LCV.WorksheetFunction.Average(LCV.Range("I3:I" & (c + 2)))