Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-16-2017, 01:48 AM
Filip88 Filip88 is offline Variable data set in Average formula Windows 10 Variable data set in Average formula Office 2016
Novice
Variable data set in Average formula
 
Join Date: Jan 2017
Posts: 12
Filip88 is on a distinguished road
Default Variable data set in Average formula

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
Attached Files
File Type: xlsx Excel Average.xlsx (9.5 KB, 13 views)
Reply With Quote
  #2  
Old 09-16-2017, 02:39 AM
Pecoflyer's Avatar
Pecoflyer Pecoflyer is offline Variable data set in Average formula Windows 7 64bit Variable data set in Average formula Office 2010 64bit
Expert
 
Join Date: Nov 2011
Location: Brussels Belgium
Posts: 2,920
Pecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond repute
Default

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
Reply With Quote
  #3  
Old 09-16-2017, 05:12 AM
Filip88 Filip88 is offline Variable data set in Average formula Windows 10 Variable data set in Average formula Office 2016
Novice
Variable data set in Average formula
 
Join Date: Jan 2017
Posts: 12
Filip88 is on a distinguished road
Default

Quote:
Originally Posted by Pecoflyer View Post
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))
It should start in A2 but the formula should affect whole range, i mean if i copy AVERAGE($A$2:INDEX($A$2:$A$12;C2)) to C5, C6, C7 etc.. it is still fixed on A2, and does not move down.. i mean the average is fixed on the 1st cell displaying average of previous values, but is not copied down does not displaying averages of followed cells.

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?
Reply With Quote
  #4  
Old 09-16-2017, 09:32 AM
Pecoflyer's Avatar
Pecoflyer Pecoflyer is offline Variable data set in Average formula Windows 7 64bit Variable data set in Average formula Office 2010 64bit
Expert
 
Join Date: Nov 2011
Location: Brussels Belgium
Posts: 2,920
Pecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond repute
Default

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
Reply With Quote
  #5  
Old 09-16-2017, 01:16 PM
ArviLaanemets ArviLaanemets is offline Variable data set in Average formula Windows 8 Variable data set in Average formula Office 2016
Expert
 
Join Date: May 2017
Posts: 932
ArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant future
Default

Into B2 enter the formula
=AVERAGE(OFFSET($A$1;ROW()-1;;;$C$2-1;1)
and copy down.
Reply With Quote
  #6  
Old 09-16-2017, 10:36 PM
xor xor is offline Variable data set in Average formula Windows 10 Variable data set in Average formula Office 2016
Expert
 
Join Date: Oct 2015
Posts: 1,100
xor is a name known to allxor is a name known to allxor is a name known to allxor is a name known to allxor is a name known to allxor is a name known to all
Default

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.
Reply With Quote
  #7  
Old 09-16-2017, 11:28 PM
Pecoflyer's Avatar
Pecoflyer Pecoflyer is offline Variable data set in Average formula Windows 7 64bit Variable data set in Average formula Office 2010 64bit
Expert
 
Join Date: Nov 2011
Location: Brussels Belgium
Posts: 2,920
Pecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond repute
Default

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
Reply With Quote
  #8  
Old 09-17-2017, 12:09 AM
xor xor is offline Variable data set in Average formula Windows 10 Variable data set in Average formula Office 2016
Expert
 
Join Date: Oct 2015
Posts: 1,100
xor is a name known to allxor is a name known to allxor is a name known to allxor is a name known to allxor is a name known to allxor is a name known to all
Default

@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.
Reply With Quote
  #9  
Old 09-17-2017, 12:47 AM
Pecoflyer's Avatar
Pecoflyer Pecoflyer is offline Variable data set in Average formula Windows 7 64bit Variable data set in Average formula Office 2010 64bit
Expert
 
Join Date: Nov 2011
Location: Brussels Belgium
Posts: 2,920
Pecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond repute
Default

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
Reply With Quote
  #10  
Old 09-17-2017, 12:54 AM
xor xor is offline Variable data set in Average formula Windows 10 Variable data set in Average formula Office 2016
Expert
 
Join Date: Oct 2015
Posts: 1,100
xor is a name known to allxor is a name known to allxor is a name known to allxor is a name known to allxor is a name known to allxor is a name known to all
Default

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.
Reply With Quote
  #11  
Old 09-17-2017, 01:57 AM
Filip88 Filip88 is offline Variable data set in Average formula Windows 10 Variable data set in Average formula Office 2016
Novice
Variable data set in Average formula
 
Join Date: Jan 2017
Posts: 12
Filip88 is on a distinguished road
Default

thank you all for help, it works great
Reply With Quote
  #12  
Old 09-17-2017, 05:34 AM
Pecoflyer's Avatar
Pecoflyer Pecoflyer is offline Variable data set in Average formula Windows 7 64bit Variable data set in Average formula Office 2010 64bit
Expert
 
Join Date: Nov 2011
Location: Brussels Belgium
Posts: 2,920
Pecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond reputePecoflyer has a reputation beyond repute
Default

Quote:
Originally Posted by xor View Post
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.
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
Reply With Quote
  #13  
Old 09-17-2017, 06:54 AM
xor xor is offline Variable data set in Average formula Windows 10 Variable data set in Average formula Office 2016
Expert
 
Join Date: Oct 2015
Posts: 1,100
xor is a name known to allxor is a name known to allxor is a name known to allxor is a name known to allxor is a name known to allxor is a name known to all
Default

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.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Variable data set in Average formula Filling a range variable into a formula Officer_Bierschnitt Excel Programming 3 11-23-2015 03:30 AM
Variable data set in Average formula Looking for formula that would create an average from certain criteria with in excel 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
Variable data set in Average formula Excel 2010 formula rounds - arithmetic average calculation YooNaa Kim Excel 1 06-07-2011 08:50 PM
'AVERAGE' Formula nfphilpot Excel 3 11-24-2010 02:19 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:08 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft