I'm trying to figure out exactly how this formula works and I've got part of it in my head, but not all of it.

The entire formula is:
=IF(COUNTIF(Sheet1!$A$3:$A$2752,$D$1)>=ROWS($1"1,INDEX(Sheet1!A$3:A$2752,SMALL(IF(Sheet1$A$3:$A$2752=$D$1,ROW($1:$1999)),ROW(1:1))),"")
At the start, I get that If the number of rows on Sheet1-A3-A2753 where the cell = what's in Input sheet-D1, then...Where I'm losing it is at INDEX and at SMALL. I think I get the If statement after small but, no matter how hard I've studied it, I can't make out what happens with INDEX and SMALL. I've googled and diagrammed and thought till my eyes crossed! I tried using Evaluate Formula, but once it gets to that second IF (after the SMALL), it lists ALL of the cells that it's looking at on Sheet1 as an array. Then, on the next step, it says if they're true or false (also as an array), which I understand. But THEN, on the next step, it shows the numbers 1-1999 as another array. It's already lost my by this time.

I'd really like to understand this, just for my own curiousity. Can anyone enlighten me?

Jenny