Do you understand how gjlindn's code? It looks like, rather than use the formula described by Wikipedia, his/her UDF simply makes a new array of "weight" copies of each "value". Then uses the built in WorksheetFunction.Median() function to derive the median. By simply changing WorksheetFunction.Median to WorksheetFunction.Percentile() or .Quartile(), you could return any quartile or percentile you wanted from the UDF.