this error usually appears when the compiler encounters some code that is supposed to be INSIDE a procedure
for example the statement
cannot stand outside a "sub ... end" sub block because then there would be no sub to exit from, right?
so what obviously happened by deleting code is, that now you got some code left, which is missing itīs beginning "sub..." statement
if u delete code accidently more often, itīs probably a good idea to export your libraries ifrom the project explorer from time to time ;-)