extraordinary average formula !!

gaftalik

Well-known Member
Joined
Feb 6, 2003
Messages
521
Office Version
  1. 2016
Platform
  1. Windows
Hello everybody!

1)Is there any formula to put in K6 which may calculates the average of the last 3 months ! should it be a macro or a formula ?
I need also a macro to calculate it automatically each time i add a month data column! :roll:

2) what is the right formula to average only the months of the year 2004 ? :roll:

Thank you very much .
Book1
BCDEFGHIJKLM
3
4
5nov.03dec.03jan.04feb.04mar.04apr.04mai.04jun.04Averagein2004Averagelast3months
63021384011262414#VALUE!??
786372326372710
8115383132273119
96341012295214
10189742881924
11
12
13
Sheet1
 
That's magic :!: i cant believe it :!:
No words can express my thanks for your everything you do,with you excel problems dont exist !

Dear Aladin ,vessels of thanks ...
 
Upvote 0

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Dear Champ,

Your last formula is one of the best i ever had and saved a lot of problems.
Trying to apply it on another workbook i couldnt succeed bymyself :cry:

I need to return the average of the "total" columns of the last xx months , but in this case i have one more column after "total"

Can you help me please ? :oops:
Always grateful champ ! Thank you a lot
question abt average.xls
HIJKLMNOPQRSTUVWXYZAA
20Averagelast2Months
21??
2212
23OctoberNovemberDecemberJanuary
24UTTOTAL%UTTOTAL%UTTOTAL%UTTOTAL%Answershouldbe
2598178%19284719%143177%32
2648105827%37377430%23194217%58
2721507133%12425422%11496024%57
2832397133%44307430%49186727%70,5
29217249186
2nd
 
Upvote 0
Sorry I'm not the champ, but in the meantime perhaps you might be able to make do with this. I'm afraid as it stands its not fully automated.

It relies on the cells you want included in the average to be identified with a y. I am sure it must be quite easy to automate the "y" but I can't think how to do it at the moment.
Any way if you can live with that the rest should work.
Book1
ABCDEFGHIJKLMNOPQR
1yy
2OctoberNovemberDecemberJanuary
3UTTOTAL%UTTOTAL%UTTOTAL%Average
498178%19284719%143177%32
548105827%37377430%23194217%58
621507133%12425422%11496024%57
732397133%44307430%49186727%70.5
Sheet1


Also, can i ask what do you do when you add a new months data? Do you insert 4 columns?

Actually On thinking about this after initial post, if you identify the cells to average with the Y then the part of the array formula looking for "total" is excess to requirements and I haven't really answered your query - sorry
 
Upvote 0
Dear GorD,

Thank you for your answer, that is very clear but since i need to change the number of months from time to time it means i have to add the "y" over each column needed.
Re columns , i already have the columns from Oct until Dec 04 on my worksheet each having same column header inside .
Once again i appreciate your concern and many thanks .
 
Upvote 0
I had a further play with trying to automate the addition of the Y to cells in the count range and the following should work (I think). I set it to count the last two months but the subtraction at the end of the formula could be adjusted to count a different number and could also ref another cell to allow you more flexibility.

Hope it is of some help
Book1
ABCDEFGHIJKLMNOPQRSTUV
1    y   y 
2OctoberNovemberDecemberjanuaryblank
3UTTOTAL%UTTOTAL%UTTOTAL%UTTOTAL%Average
498178%19284719%143177%98178%17
548105827%37377430%23194217%48105827%50
621507133%12425422%11496024%21507133%65.5
732397133%44307430%49186727%32397133%69
Sheet1


Formula in G1 is

=IF(AND(G3="total", COLUMN(G:G)>=(MATCH(9.99999999999999E+307,$A4:$T4)-6)),"y","")
 
Upvote 0
It could be a solution if i keep the remaining columns blank, i think you can figure what Aladdin did in the previous formula better than me and maybe we will succeed to apply it on this worksheet. Frankly,i got dizzy looking for hours trying to decode that formula piece by piece :banghead:

GorD, thank you for being so patient with me :-D
 
Upvote 0
if you want to add a new month select columns q,r,s,t, and right click insert. The formulas should adjust- just always keep one group of 4 as blanks at the end.

Does that not work?
 
Upvote 0
It can work but what about if i want the average to be 3 , 4 or 5 upon my request , how to set that simply by editing the needed number in a cell ?
 
Upvote 0
I haven't tested this but the thinking was that in the formula

=IF(AND(G3="total", COLUMN(G:G)>=(MATCH(9.99999999999999E+307,$A4:$T4)-6)),"y","")

Insted of having a hard wired value (red above) you could change this to ref another cell which would be related to how many values you want in the average. You /we would have to work out that relationship The example I have used used 2 values. If you wanted more values included inn the range the 6 being subtracted would be a lesser number.

If I get some time later I'll try and see if I can get it to work, but in principal I think it should work.
 
Upvote 0

Forum statistics

Threads
1,224,881
Messages
6,181,536
Members
453,054
Latest member
ezzat

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top