The code has to be pasted in a code module, and not in the sheet module or workbook module. Also ensure that the cell you're using is locked.