I am trying to build a custom function in VBA that will allow me to apply standard QUARTILE formula for filtered (i.e. visible) data in the worksheet. As you know the standard QUARTILE formula still considers data that is hidden through filters.
The code that I have come up so far for this function looks as follows:
https://i.stack.imgur.com/bT52X.jpg
Function QuartileFiltered(Used_Range As Range, number As Long)
Dim Filtered_Range As Range
Filtered_Range = Used_Range.SpecialCells(xlCellTypeVisible).Select
QuartileFiltered = WorksheetFunction.Quartile(Filtered_Range, number)
End Function
This unfortunately doesn't work. Could you please help me to fix it, I would be very gratefull for it!
Regards, Max