Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Range.Average Problem

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)))
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Range.Average Problem

Change

LCV.WorksheetFunction.Average

to

WorksheetFunction.Average

HTH,
Barb Reinhardt
"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)))

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Range.Average Problem

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)))

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Range.Average Problem

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)))

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Range.Average Problem

LCV.Range has numbers and is formatted as Numbers and not text... I averaged
it separtely from the code and I got a valid answer... what am I doing wrong
:(

"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)))



  #6   Report Post  
Posted to microsoft.public.excel.programming
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)))

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Range.Average Problem

WorksheetFunction is a member of the Application object. Try:

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

where xlApp is a variable that holds the application object. If you don't
have a variable for the application, try:

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


--
Hope that helps.

Vergel Adriano


"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)))

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Range.Average Problem

Ok, I figured out whats going on.... but I'm not sure how to correct it. The
reason I'm getting all zeros is because either my numbers are less than 0.5
or they are negative. I don't know why its rounding. Any ideas on how to
correct this?

"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)))

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Range.Average Problem

Thanks everyone for the help... I thought you might like to know that I
solved it... I guess its been a long day of coding...but I had CSVCICAvg
Dimmed as Integer rather than Double and it was rounding to zeros... Sorry
about that, but thanks for the help!

"Vergel Adriano" wrote:

WorksheetFunction is a member of the Application object. Try:

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

where xlApp is a variable that holds the application object. If you don't
have a variable for the application, try:

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


--
Hope that helps.

Vergel Adriano


"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)))

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
AVERAGE a range in a column if another column's range equals a val bob$ Excel Discussion (Misc queries) 3 February 24th 09 07:42 AM
Zero in Average problem Gizmo Excel Discussion (Misc queries) 7 May 7th 08 03:53 AM
Problem with average Moperk23 Excel Discussion (Misc queries) 2 April 18th 08 03:18 PM
Average Problem Paul Excel Worksheet Functions 3 February 10th 07 04:44 PM
AVERAGE problem malik641 Excel Worksheet Functions 3 July 21st 05 04:04 AM


All times are GMT +1. The time now is 05:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"