Function Average(Sum, Count) As Double ' Calculate average from Sum and Count If Count = 1 Then Average = Sum ElseIf Count > 0 Then Average = Sum / Count Else Average = 0 ' Invalid value of Count End If End Function