I use local name ranges for calculations (i.e. their scope is only within a particular sheet), rather than global named ranges, which apply to an entire workbook. If I have two sheets in a workbook with the same local named range in them, I've noticed that there seems to be a bug.
E.g. I have a range "ClientName" in both Sheet1 and Sheet2 of workbook "Book1". I can read from and write to both names and it seems to work fine. But the property "Worksheet" on the names will both be "Sheet1".
Where this breaks is when I try to copy the entirety of Sheet2 into a different workbook, "Book2". The CopySheetNames() private method in ExcelWorksheets freaks out over the reference to a Worksheet that doesn't exist in Book2, so a null reference exception gets thrown.
I think the issue needs to be traced back to when the ExcelNamedRanges are constructed in the first place. I haven't had a go at fixing it myself in case it's already on your radar, but I'm happy to dig in if it's not.
EDIT - Sorry, user error. Ignore this. How do I delete it?
E.g. I have a range "ClientName" in both Sheet1 and Sheet2 of workbook "Book1". I can read from and write to both names and it seems to work fine. But the property "Worksheet" on the names will both be "Sheet1".
Where this breaks is when I try to copy the entirety of Sheet2 into a different workbook, "Book2". The CopySheetNames() private method in ExcelWorksheets freaks out over the reference to a Worksheet that doesn't exist in Book2, so a null reference exception gets thrown.
I think the issue needs to be traced back to when the ExcelNamedRanges are constructed in the first place. I haven't had a go at fixing it myself in case it's already on your radar, but I'm happy to dig in if it's not.
EDIT - Sorry, user error. Ignore this. How do I delete it?