Hey everyone, I’ve got this user-defined function that I use to calculate a statistical measure for a range of cells. I’d like to modify it so that it only evaluates the visible cells within the range, but I’m not sure exactly how…
Here’s the current code:
I think I need to modify with something like this, but this doesn’t seem to work so not sure… any ideas?
When you initially run the function, it prompts the user to select a range. I'd like to be able to select a table column for example, but have the function re-evaluate based on the visible cells only as the table gets filtered...
Thanks in advance!
Joe
Here’s the current code:
VBA Code:
Function COD(r As Range) As Double
Dim sAdr As String
Dim sFrm As String
sAdr = r.Address
sFrm = "average(abs(" & sAdr & " - median(" & sAdr & ")))/median(" & sAdr & ")"
COD = r.Worksheet.Evaluate(sFrm)
End Function
I think I need to modify with something like this, but this doesn’t seem to work so not sure… any ideas?
Code:
sAdr = r.SpecialCells(xlCellTypeVisible).Address
When you initially run the function, it prompts the user to select a range. I'd like to be able to select a table column for example, but have the function re-evaluate based on the visible cells only as the table gets filtered...
Thanks in advance!
Joe