Find the average and place it 2 rows down from the last row

nguerra

New Member
Joined
Oct 1, 2013
Messages
36
I know this is easier than I'm making of it. I have a column of numbers starting at B2 and goes some number of rows that will change over time. I would like to average the column and place the average two rows below the last row. Any help would be greatly appreciated.
 

Some videos you may like

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
13,425
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
Try...
VBA Code:
Sub AverageB()
    Dim LastB As Range
    Set LastB = Range("B" & Rows.Count).End(xlUp)
    LastB.Offset(2) = Application.Average(Range("B2", LastB))
End Sub
 

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
19,392
Office Version
  1. 2013
Platform
  1. Windows
Try using
VBA Code:
Sub MM1()
Dim lr As Long
lr = Cells(Rows.Count, "B").End(xlUp).Row
Range("B" & lr + 2).Formula = "=Average(B2:B" & lr & ")"
End Sub
 

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
13,425
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
You're welcome, happy we could help.
 

Watch MrExcel Video

Forum statistics

Threads
1,113,890
Messages
5,544,887
Members
410,643
Latest member
sng
Top