Have a look at NBVC's answer here

http://www.excelforum.com/excel-gene...-function.html