dynamic average formula

daveyc18

Well-known Member
Joined
Feb 11, 2013
Messages
782
Office Version
  1. 365
  2. 2010
current formula

=AVERAGE(Z39:AG39)

this is because column Z starts with "P1 2024" and column AG has "p8 2024"

this will eventually go to column AK to "P12 2024"

is there a way to make this formula dynamic where it always look for P1 XXXX (XXXX being the current year) then ends in the last non-blank column

so the formula is not only dyanmic in picking up the last non-blank column, but also dynamic in terms of the year (ie when it becomes 2025, I dont need to adjust the starting point of the formula to point to the column with "P1 2025")
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
try this formula:
Excel Formula:
=AVERAGE(OFFSET(A39,0,MATCH("P1 " & YEAR(TODAY()),$A$1:$BK$1)-1,1,MONTH(TODAY())))
You can extend the ragne A1 to BK1 to any size you like.
I have assumed that the 8 in the P8 2024 title refers to the month, so that I can find the offset from the start of the average but just finding the width of the range in the offset by using the month number
 
Upvote 0
Solution

Forum statistics

Threads
1,224,813
Messages
6,181,116
Members
453,021
Latest member
Justyna P

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