I am trying to create a macro to enter a formula for the average of all the cells I have selected in the cell immediately below the selected range. I can not seem to find the correct syntax. Here is the code I have thus far.
Any ideas on how to get this to work? Any help is appreciated!
Code:
Sub Test()Dim x As Range, y As Range
Set x = Selection
With Selection.Offset(Selection.Rows.Count).Resize(1, 1)
.Select
End With
Set y = ActiveCell
y.FormulaR1C1 = "=Average(x)"
With Selection.Font
.Bold = True
End With
End Sub