When a routine uses a separate SUB program, and is pasted directly into the QB window header, sometimes the IDE tosses the SUB name into the SUB area and automatically adds END SUB before the end sub that you have already copied. Thus you have two END SUB's!
The IDE will tell you that you cannot have anything before the second END SUB. Just cut or delete out the second end sub line.
In any separate SUB routine, you can get that message also, if you try to put something before the SUB line at the beginning. Only a DEFINT or other number type DEF can be there. Otherwise it will try to add a comment out ' mark.
An easier way is to copy the code into Notepad and save it as a BAS file. I have included an answer for Windows and Mac has shown a way using DOS.