Explanation
At the core, this formula looks for a line delimiter ("delim") and replaces it with a large number of spaces using the SUBSTITUTE and REPT functions.
Note: In older versions of Excel on a Mac, use CHAR(13) instead of CHAR(10). The CHAR function returns a character based on it's numeric code.
The number of spaces used to replace the line delimiter is based on the total length the text in the cell. The formula then uses the MID function to extract the desired line. The starting point is worked out with:
(N-1)*LEN(A1)+1 // start_num
Where "N" stands for "nth line", which is picked up from row 4 with the D$4 reference.
The total characters extracted is equal to the length of the full text string:
LEN(A1) // num_chars
At this point, we have the "nth line", surrounded by spaces.
Finally, the TRIM function slices off all extra space characters and returns just the line text.
Text to Columns
Don't forget that Excel has a built-in Text to Columns feature that can split text according to the delimiter of your choice, though it is not a dynamic solution like a formula. On Windows, you can type Control + J to enter the equivalent of a new line character for the "Other" delimiter. You can also use Control + J for new line during search and replace operations.
I'm not sure how to enter a new line character in Mac Excel, as a delimiter, or in the search and replace dialog. If you know how, please leave a comment below.