You added it to the spreadsheet, but did you insert it into a Standard Module (*not* the Sheet1, Sheet2, ThisWorkbook modules)? In the VB Editor window, click Insert > Module and paste the code there. It should work as intended.
Also note that it will only accept a cell reference, not a value. It would need changing if you wanted to use values instead.
Bookmarks