Hi, I have been given a great code from one of the users on here, and have opened my macros window through one of my open workbooks. I then inputted the exact code I have been given, and it works. I need to use this feature in a few workbooks, but when I go to a different workbook, and click 'open macros' and select the on ei need, with exactly the same code, it says 'expected end sub', and the 'sub Prime ()' has turned yellow.

I dont really know anything about this stuff, but I cant understand why it works in one, and I can use it freely, but wont work in a different one.

Any ideas?

Thanks!