![]() |
|
#1
|
|||
|
|||
![]()
Hello,
i have range of cells (column A). I want to count average from data from Column A in column B, but the range of average should be able to change based on my input in cell C2. It means when i input number 3 in C2, it should count average of 3 cells from column A, if i input 10 in C2, it should count average of 10 cells etc. Based on my input in cell C1 the formulas in column B would use different data set to be processed. Basically column A has data, column B has formulas to be changed based on input of cell C2 Is somehow possible to do that in excel formulas? Or it is inevitable to use VBA? I would appreciate if somebody has any advice. I have attached excel sheet. Thank you Filip |
#2
|
||||
|
||||
![]()
You do not say where the range should begin. Should it always start in A2 ?
Then =AVERAGE($A$2:INDEX($A$2:$A$12;C2))
__________________
Using O365 v2503 - Did you know you can thank someone who helped you? Click on the tiny scale in the right upper hand corner of your helper's post |
#3
|
|||
|
|||
![]() Quote:
I guess should i use two index function within average formula? So the average is counted at each followed cell in column C based on C2 value? |
#4
|
||||
|
||||
![]()
Try this in B2 =IF((ROW()-$C$2)>0,AVERAGE($A2:INDEX($A$2:$A$12,ROW()-$C$2)),"") and pull down as needed
__________________
Using O365 v2503 - Did you know you can thank someone who helped you? Click on the tiny scale in the right upper hand corner of your helper's post Last edited by Pecoflyer; 09-17-2017 at 12:46 AM. Reason: Correction Thanks Xor |
#5
|
|||
|
|||
![]()
Into B2 enter the formula
=AVERAGE(OFFSET($A$1;ROW()-1;;;$C$2-1;1) and copy down. |
#6
|
|||
|
|||
![]()
I would use (in B2 and copy down)
=IF(ROW(2:2)-$C$2<0;"";AVERAGE(OFFSET($A$2;ROWS($1:1);;-$C$2))) on condition you use semicolon as argument separator. |
#7
|
||||
|
||||
![]()
Why use a volatile function when one can do without it?
__________________
Using O365 v2503 - Did you know you can thank someone who helped you? Click on the tiny scale in the right upper hand corner of your helper's post |
#8
|
|||
|
|||
![]()
@Pecoflyer
My apologies if it is me you write to. I tried your formula and couldn't get it to work at first. Now I see it was due to the fact that you use a § instead of $ in your formula. When I corrected that it works fine, and I agree in your comment on volatile functions. |
#9
|
||||
|
||||
![]()
Thanks Xor for pointing this out. I had to look three times before I saw it.
Strangest thing is I just copy/pasted the formula form Openoffice ( and changed the ; to ,) (Sometimes Linux does strange things)
__________________
Using O365 v2503 - Did you know you can thank someone who helped you? Click on the tiny scale in the right upper hand corner of your helper's post |
#10
|
|||
|
|||
![]()
Exactly the same for me. I then used the Formula Evaluator and could see that it was somewhere in the INDEX part that something went wrong but couldn't find the error. That's the reason that I decided to use OFFSET.
|
#11
|
|||
|
|||
![]()
thank you all for help, it works great
![]() |
#12
|
||||
|
||||
![]()
Also a Linux guy ( or lady)?
__________________
Using O365 v2503 - Did you know you can thank someone who helped you? Click on the tiny scale in the right upper hand corner of your helper's post |
#13
|
|||
|
|||
![]()
No, not a Linux guy. I just meant that I took me some time to catch the §-thing even if I from the Formula Evaluator could see that it was the INDEX-part of the formula that gave a #NAME?-error. Normally I would also have used the INDEX-function, but as I initially couldn't catch the error, I turned to OFFSET.
|
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
Officer_Bierschnitt | Excel Programming | 3 | 11-23-2015 03:30 AM |
![]() |
bdouglas1011 | Excel Programming | 7 | 07-29-2014 08:16 AM |
formula to find 2 or more criterias then average the sum | samtitus | Excel | 6 | 02-17-2014 10:16 PM |
![]() |
YooNaa Kim | Excel | 1 | 06-07-2011 08:50 PM |
'AVERAGE' Formula | nfphilpot | Excel | 3 | 11-24-2010 02:19 PM |