=IF(ISERROR(INDEX($A$1:$B$1006,SMALL(IF($A$1:$A$1006=$E$3,ROW($A$1:$A$1006)),ROW(1:1)),2)),"",INDEX($A$1:$B$1006,SMALL(IF($A$1:$A$1006=$E$3,ROW($A$1:$A$1006)),ROW(1:2)),2))

the problem I am running into is that this function will show multiple results (so for example activity 299 has two successors). So I can either space out all of the cells to create this worksheet but ideally, I would like to create a VBA or function that would detect if the cell has a value in it and insert a new row underneath copying to formulas down.

I know how to use macros however I am a beginner at writing them. If someone could help me write one I would be much appreciative.

If it would make it easier I can also email a copy of the worksheet