Exporting to excel part 2

Yes, no wonder.
You did not replace

(which is still there in your script)
but simply added another $loop(), this time

at the end.
And obviously, you did not have a look at the documentation as otherwise you would know by now the syntax for $loopend() which has already been revealed to you also in this thread:

Thirdly, I think that you still have not inserted the paragraph/lin break in front of the $loop() statement.
And as all these are changes that I cannot do for you as you have to adapt your script locally, I cannot help you any further.

And @MotleyG is right: I am just a plain user and participant in this forum, no MP3tag developer. So I learned to write export scripts just like you would have to.
If you cannot adapt the script, then it would be time to think about an alternative to the Excel export.
In some other thread I asked you:

so perhaps a closer look at the other MP3tag functions could avoid the problem with the export script.