You have two problems. I will try to help with the first, and will try not to make your life too miserable by pointing out the second without helping much.
The easy way to attack the first problem is to build column AA (outside the pivot table range), with the following formula in cell AA1
HTML:
=if(b1<0,xirr(b1:b$100,$a1:$a$100,0.1),"")
then copy this formula to cells aa2 through aa100 (or whatever), and to columns ab through az. Each column from aa to az will then contain one number (the IRR) and a lot of blanks. You can then use something like
=max(aa1:aa100) to return the IRR, regardless which row it turns up in.
The second problem is that IRR is not a terribly good way of evaluating alternative investments. Unfortunately it is the favoured approach of Dilbert-style pointy-haired bosses who understand that a big IRR is better than a small one, but don't really understand discounted cash flow analysis or risk evaluation. Much better to first decide on a cost of capital and then look at things on a present-value basis.
One limitation of using rate-of-return is that it only works if you have a negative cash flow followed by a number of positive ones. If the cash flow stream starts with a positive number (maybe an upfront payment) then goes negative and positive again, then XIRR won't work, and neither will my suggestion above. If the initial cash flow is negative, followed by a mixture of positive and negative cash flows (a "nonconventional investment"), you can get multiple rates of return, and Excel will only tell you about the one it happens to find first. This situation is common where you have a base case investment A, and are trying to decide if you should do an add-on such as an acceleration-type investment. Subtracting the base case from the accelerated case will often give a nonconventional series of cash flows, and two rates of return will satisfy the condition PV=0. Often the two rates of return will be quite different (say -10% and +15%), but if you look at the PV's of the two investment alternatives, the difference might be quite small.
The second shortcoming of the rate-of-return approach is that it does not distinguish between magnitudes of investments. Would you prefer a $1 investment where you get $10 at the end of the year, or a $10,000 investment where you get $20,000 at the end of the year? The first choice has a much higher IRR ...
There are other problems with IRR, but I think I've used up enough board space with my rant!
Hope this helped a bit ...