Thanks to both of you.
Yes, I am using vba, and no, I have not recorded a macro, but I have written myself all that code.
To the previous post, yes, I did try using "dim x as double" instead of "dim x as integer", and it didn't get rid of any of the 36 "error 13" I get. The other...