Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2
Default Get Current Row for use in INDIRECT function

Goal: Average a number of cells based on a variable (located in $F$4) that
tells the function how many rows to average.

Currently the cells look like following and obviously average the next 10
rows, which is fine until I wish to change the average to include the next 15
or 20 or 100 rows instead of the hardcoded 10 rows.

cell y5 =AVERAGE(Z5:Z15)
cell y6 =AVERAGE(Z6:Z16)
cell y7 =AVERAGE(Z7:Z17)

So I'm trying to create a function that will allow me to use the value at
$F$4 to determine the "size" of the range
pseduo code is: =AVERAGE(Z5:Z(5+$F$4))

I get about this close: =AVERAGE(INDIRECT("Z" & FUNCTION(current_row) &
":Z" & FUNCTION(current row)+$F$4))

any and all help is appreciated...
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 434
Default Get Current Row for use in INDIRECT function

hi, ?

Goal: Average a number of cells based on a variable (located in $F$4)
that tells the function how many rows to average [...]
So I'm trying to create a function that will allow me to use the value at $F$4
to determine the "size" of the range
pseduo code is: =AVERAGE(Z5:Z(5+$F$4))
I get about this close: =AVERAGE(INDIRECT("Z" & FUNCTION(current_row)
& ":Z" & FUNCTION(current row)+$F$4))
any and all help is appreciated...


assuming 'F4' includes 'starting' row for the 'sizeable' range...
how about: =average(offset(z5,,,$f$4,))

hth,
hector.


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 15,768
Default Get Current Row for use in INDIRECT function

Another way:

=AVERAGE(Z5:INDEX(Z5:Z1000,F$4))

Adjust for the end of the range.

If F4 is empty the entire range will be calculated.

Biff

"TBONE6540" wrote in message
...
Goal: Average a number of cells based on a variable (located in $F$4) that
tells the function how many rows to average.

Currently the cells look like following and obviously average the next 10
rows, which is fine until I wish to change the average to include the next
15
or 20 or 100 rows instead of the hardcoded 10 rows.

cell y5 =AVERAGE(Z5:Z15)
cell y6 =AVERAGE(Z6:Z16)
cell y7 =AVERAGE(Z7:Z17)

So I'm trying to create a function that will allow me to use the value at
$F$4 to determine the "size" of the range
pseduo code is: =AVERAGE(Z5:Z(5+$F$4))

I get about this close: =AVERAGE(INDIRECT("Z" & FUNCTION(current_row) &
":Z" & FUNCTION(current row)+$F$4))

any and all help is appreciated...



  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,718
Default Get Current Row for use in INDIRECT function

=AVERAGE(Z5:INDIRECT("Z"&ROW(Z5)+$F$4))


"TBONE6540" wrote:

Goal: Average a number of cells based on a variable (located in $F$4) that
tells the function how many rows to average.

Currently the cells look like following and obviously average the next 10
rows, which is fine until I wish to change the average to include the next 15
or 20 or 100 rows instead of the hardcoded 10 rows.

cell y5 =AVERAGE(Z5:Z15)
cell y6 =AVERAGE(Z6:Z16)
cell y7 =AVERAGE(Z7:Z17)

So I'm trying to create a function that will allow me to use the value at
$F$4 to determine the "size" of the range
pseduo code is: =AVERAGE(Z5:Z(5+$F$4))

I get about this close: =AVERAGE(INDIRECT("Z" & FUNCTION(current_row) &
":Z" & FUNCTION(current row)+$F$4))

any and all help is appreciated...

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2
Default Get Current Row for use in INDIRECT function

Thanks to all... Here's what I have at the moment:

=AVERAGE(INDIRECT("Z"&ROW()&":Z" & ROW()+$F$4))

The problem now is that if I insert a column before the Z column, everthing
gets screwed up... I need the "Z" reference in the INDIRECT statement to be
adjusted if I add or delete columns...

"Teethless mama" wrote:

=AVERAGE(Z5:INDIRECT("Z"&ROW(Z5)+$F$4))


"TBONE6540" wrote:

Goal: Average a number of cells based on a variable (located in $F$4) that
tells the function how many rows to average.

Currently the cells look like following and obviously average the next 10
rows, which is fine until I wish to change the average to include the next 15
or 20 or 100 rows instead of the hardcoded 10 rows.

cell y5 =AVERAGE(Z5:Z15)
cell y6 =AVERAGE(Z6:Z16)
cell y7 =AVERAGE(Z7:Z17)

So I'm trying to create a function that will allow me to use the value at
$F$4 to determine the "size" of the range
pseduo code is: =AVERAGE(Z5:Z(5+$F$4))

I get about this close: =AVERAGE(INDIRECT("Z" & FUNCTION(current_row) &
":Z" & FUNCTION(current row)+$F$4))

any and all help is appreciated...



  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 434
Default Get Current Row for use in INDIRECT function

hi, !

Thanks to all... Here's what I have at the moment:
=AVERAGE(INDIRECT("Z"&ROW()&":Z" & ROW()+$F$4))
The problem now is that if I insert a column before the Z column, everthing gets screwed up...
I need the "Z" reference in the INDIRECT statement to be adjusted if I add or delete columns...


AFAIK indirect function uses *frozen*/text references
it does not care if you insert/delete rows/columns... it will point always to the quoted text

you have other approaches as for to give them a try
or you can play with other information functions [colum, address, cell, etc.]
and -probably- you will get a *kilometrical* formula at the end -?-

hth,
hector.


  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4,339
Default Get Current Row for use in INDIRECT function

If any column insertion is AFTER column F, use Biff's formula:

=AVERAGE(Z5:INDEX(Z5:Z1000,F$4))

Insertion before F will change $F$4 reference.

"TBONE6540" wrote:

Thanks to all... Here's what I have at the moment:

=AVERAGE(INDIRECT("Z"&ROW()&":Z" & ROW()+$F$4))

The problem now is that if I insert a column before the Z column, everthing
gets screwed up... I need the "Z" reference in the INDIRECT statement to be
adjusted if I add or delete columns...

"Teethless mama" wrote:

=AVERAGE(Z5:INDIRECT("Z"&ROW(Z5)+$F$4))


"TBONE6540" wrote:

Goal: Average a number of cells based on a variable (located in $F$4) that
tells the function how many rows to average.

Currently the cells look like following and obviously average the next 10
rows, which is fine until I wish to change the average to include the next 15
or 20 or 100 rows instead of the hardcoded 10 rows.

cell y5 =AVERAGE(Z5:Z15)
cell y6 =AVERAGE(Z6:Z16)
cell y7 =AVERAGE(Z7:Z17)

So I'm trying to create a function that will allow me to use the value at
$F$4 to determine the "size" of the range
pseduo code is: =AVERAGE(Z5:Z(5+$F$4))

I get about this close: =AVERAGE(INDIRECT("Z" & FUNCTION(current_row) &
":Z" & FUNCTION(current row)+$F$4))

any and all help is appreciated...

  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,231
Default Get Current Row for use in INDIRECT function

"T. Valko" wrote...
Another way:

=AVERAGE(Z5:INDEX(Z5:Z1000,F$4))

Adjust for the end of the range.

If F4 is empty the entire range will be calculated.

....

Which could be trapped using

=AVERAGE(Z5:INDEX(Z5:Z1000,MAX(1,F$4)))

which also implicitly handles F4 containing non-numeric text.

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
indirect function ah Excel Worksheet Functions 1 January 25th 07 12:22 PM
Indirect Function Jim May Excel Worksheet Functions 10 November 12th 06 07:29 PM
INDIRECT function Alberto Pinto Excel Worksheet Functions 2 April 26th 06 02:33 AM
Help with INDIRECT function. DaveO Excel Worksheet Functions 12 January 18th 06 09:52 AM
Using the Indirect.Ext function henryhbb Excel Worksheet Functions 1 October 27th 04 05:56 PM


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