I am making a search tab that looks through an extensive database, and displays the top results. It is set up so that I can have the results be alphabetized if I want. The trouble is, there seems to be something wrong with my alphabetization formula.

Alphabetization example.xls

I have made a simplified version of my table in the attached spreadsheet (Excel 2004). If you search for 'a', it's fine. But if you search for 'b', the first match is not displayed as result #1. The problem seems to be that column A is ranking all of column D, when I want it to only rank from among the rows where column C is not blank. I am not sure how to accomplish that.

Any formula mods or advice would be greatly appreciated- thanks!