The code below pastes clipboard and then stretches the pasted formula. But occasionally I get subscript is out of range error. Why is that?

I use this code for sheet called TOC


HTML Code: