The code must also be in the same workbook to use the codename directly, or you must set a reference to the target workbook from the code workbook. You can also loop through all the sheets and check the codename form another workbook.