# Thread: Average of recent entries

1. ## Average of recent entries

I have a spread sheet, Excel, with golf scores. I would like to calculate the average of the ten most recent entries without varying the formula, i.e., how do I have the formula recognize the last ten entries?

2. Sully,

Here's one approach.

Assuming your dates are in A and Scores in B
Two rows below your last score in B enter this formula:
Now just remember to always place your cursor in the blank row between the last score and average and insert a new row there when you want to add another date/score pair.
Running Average.JPG
HTH

3. An alternate to RG's formula is a User Defined Function (UDF):

Enter in the Total Average row (B21) the formula =AverageScore()

You can insert as many date/scores rows as you like, the code will adjust to calculate 10 most recent.

HTH,
Maud

AverageGolfScore1.png

Place in a standard module:
Code:
```Public Function AverageScore()
Application.Volatile
Dim rng As Range
LastRow = ActiveSheet.Cells(Rows.Count, 2).End(xlUp).Row
Set rng = Range(Cells(LastRow - 10, 2), Cells(LastRow - 1, 2))
AverageScore = WorksheetFunction.Round(WorksheetFunction.Average(rng), 1)
End Function```

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•