First, I think my point was not clear. I am not saying that your problem has to do with the file mean.txt. But if I do not have the file mean.txt, I cannot run your code and therefore cannot diagnose the problem reliably.

However, looking at the line of code you showed

    Windows("WETSPA_ANALYSIS_TOOL").Activate
I think what is intended is

    ThisWorkbook.Activate
and for

    Windows("mean.txt").Activate
I would use

   Workbooks("mean.txt").Activate
But I can't test this without the file mean.txt.

(Also, the code here is very inefficient. It might work but it looks like it was developed using the macro recorder for guidance, so generates a lot more code than what is necessary. There is too much code for me to try to help with that though.)