Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Variable sized average macro/function

Hi everyone,

I'm at a loss on how to do something, hopefully some guru here can
help.

I need to take a "variable-sized average" of data, and for the life of
me, I can't get it to work with VBA / macros, etc... The best way to
illustrate what I want to do is to describe what I am doing today, and
the shortcomings will become obvious.


- I have data in A1:A100 such as 1, 2, ...100
- I have data in B1:100 such as 10, 20, ... 1000
- I have a value in Z1 of 5
- Columns A and B are data
- Cell Z1 is the number of samples to average


Right now, in column D1, I have something like this:

D5 = AVERAGE(A5:A1)
D6 = AVERAGE(A6:A2)
D7 = AVERAGE(A7:A3)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Variable sized average macro/function

=IF(ROW()<$Z$1,"",AVERAGE(INDIRECT("A"&ROW()&":A"& ROW()-$Z$1+1)))

You could also use the offset function

=IF(ROW()<$Z$1,"",AVERAGE(OFFSET(INDIRECT("A"&ROW( )),-$Z$1+1,0,$Z$1,1)))

--
Regards,
Tom Ogilvy


"danwtf2004 " wrote in message
...
Hi everyone,

I'm at a loss on how to do something, hopefully some guru here can
help.

I need to take a "variable-sized average" of data, and for the life of
me, I can't get it to work with VBA / macros, etc... The best way to
illustrate what I want to do is to describe what I am doing today, and
the shortcomings will become obvious.


- I have data in A1:A100 such as 1, 2, ...100
- I have data in B1:100 such as 10, 20, ... 1000
- I have a value in Z1 of 5
- Columns A and B are data
- Cell Z1 is the number of samples to average


Right now, in column D1, I have something like this:

D5 = AVERAGE(A5:A1)
D6 = AVERAGE(A6:A2)
D7 = AVERAGE(A7:A3)



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Variable sized average macro/function

Thanks Tom! That is working great.

I appreciate the help very much.

da

--
Message posted from http://www.ExcelForum.com

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
variable average Sue in Illinois Excel Discussion (Misc queries) 3 January 14th 09 04:40 PM
SUMIF/SUMPRODUCT Criteria are Variable Sized Thomas [PBD] Excel Discussion (Misc queries) 3 May 19th 08 05:19 PM
Average the last eight or nine (Variable) numbers in a row. Michael Excel Discussion (Misc queries) 3 December 11th 07 09:55 PM
Using variable sized range in CountIf() [email protected][_2_] Excel Discussion (Misc queries) 1 October 24th 07 11:15 AM
Summing a variable sized range programmatically Norma[_2_] Excel Programming 3 August 24th 03 07:31 PM


All times are GMT +1. The time now is 04:56 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"