LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default average on qty

I am trying to make a function that makes the average of number of inputs
based on a bigger input qty array, to keep dividing by the same number l need
to throw out of the sum the lowest index to divide by the same number, this
is part of the code I have but I don't know how to make an array output, it
does not work.

Function my_avg(data(), j As Integer) As Double

' Function passes an array of data(), and returns an array of data after
' calculates my_avg, which is the sum of data divided by number of data
' my_avg begins with a sum of one data up to a max of j, if data input is
' higher than j, division will be done to j, and sum will throw out the
' lower index.

my_avg = 0

For i = 0 To UBound(data)
If i < 15 Then
my_avg = (my_avg + data(i)) / (i + 1)
If i = 15 Then
my_avg = (my_avg + data(i)) / j
If i 15 Then
my_avg = (my_avg + data(i) - data(i - 15)) / j
End If
Next i
End Function

--
Tajin
 
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
A formula to AVERAGE IF but only average a set number of values [email protected] Excel Worksheet Functions 2 January 31st 08 08:28 PM
Find monthly average but have average automatically configured kimbafred Excel Discussion (Misc queries) 2 August 8th 07 12:28 AM
Error Handling #N/A with AVERAGE Function - Average of values in Row Sam via OfficeKB.com Excel Worksheet Functions 13 July 31st 05 03:59 PM
Weighed Average of a weiged average when there are blanks krl - ExcelForums.com Excel Discussion (Misc queries) 1 July 6th 05 07:37 PM
how does one convert text to a formula "average(A:A)" to =average( phshirk Excel Worksheet Functions 4 April 14th 05 01:20 AM


All times are GMT +1. The time now is 09:23 PM.

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

About Us

"It's about Microsoft Excel"