Welcome to the forum Chove.
Financial functions aren't my long suit but I believe this is correct. Copy and paste this formula into D1 and copy down.
Formula:
=IF(COUNTIF(A$1:A1,A1)=1,XIRR(INDEX($C:$C,MATCH($A1,$A:$A,0)):INDEX($C:$C,MATCH($A1,$A:$A)),INDEX($B:$B,MATCH($A1,$A:$A,0)):INDEX($B:$B,MATCH($A1,$A:$A))),"")
There is a shorter way to do this but it is volatile. If the "hundreds of lines" exceeds 1000 this might cause your calculations to slow down.
Formula:
=IF(COUNTIF(A$1:A1,A1)=1,XIRR(OFFSET(C1,COUNTIF(A$1:A1,A1)-1,,COUNTIF($A:$A,A1)),OFFSET(B1,COUNTIF(A$1:A1,A1)-1,,COUNTIF($A:$A,A1))),"")
Also I am not familiar with Mac product numbers and functions available, but check and see if the FILTER function will work on your Mac. If it will this can be simpler still.
Formula:
=IF(COUNTIF(A$1:A1,A1)=1,XIRR(FILTER($C$1:$C$25,$A$1:$A$25=A1),FILTER($B$1:$B$25,$A$1:$A$25=A1)),"")
Bookmarks