Hi, my first post and very new to VBA so any help appreciated. I'm trying to create a function to calculate the average of a range of cells in a column. The first cell is always the cell to the left of the cell where the UDF will be used, the last cell in the range will depend on a parameter passed to the function ie if 3 is passed, the range will be three cells deep etc
I thought this would work but no joy
Function wkavg(hours As Single)
ActiveCell.FormulaR1C1 = "=SUM(RC[-1}:R[" & hours & "]C[-1])"
End Function
Any ideas please? Thanks.
I thought this would work but no joy
Function wkavg(hours As Single)
ActiveCell.FormulaR1C1 = "=SUM(RC[-1}:R[" & hours & "]C[-1])"
End Function
Any ideas please? Thanks.