This is going to sound newbish, but I need help figuring out what I'm doing wrong here.
I want to write a function that essentially takes a range and if the average in the range is > 8, color every cell in the range using interiorindex. I attempt to write it but I keep getting a #VALUE error.
Check it out:
Public Function avgdays(Rng As Range)
avgdays = "=AVERAGE(" & Rng & ")"
If ActiveCell.Value > 8 Then
For Each cell In Rng
cell.Interior.ColorIndex = 6
Next
End If
End Function
I had 6 values from Range("A1") to Range("F1") and whenever I type in =avgdays("A1:F1"), I get #VALUE ....
I've never written functions before. What am I doing wrong here?
Start Free Trial