Where are you putting the code? It must go in the ThisWorkbook module.