Why did this code stop working?
I've used Excel range names scoped to the Workbook level in VBA for decades without, in most situations, having to qualify Range() objects with their Sheets() object parent. Recently, this stopped working and now throws a 1004 error if the named range is not on the active worksheet.
Code that used to work
If Range("SNAP_Current").Value = Range("SNAP_Backup").Value Then
debug.print "True"
else
debug.print "False"
End If
In this case, "SNAP_Current" is on the active worksheet and "SNAP_Backup" is Not on the active worksheet. Of course, the code works if Range() is qualified with the correct Sheet() object.
If Range("SNAP_Current").Value = **Sheets("Backup Copy").**Range("SNAP_Backup").Value Then
debug.print "True"
else
debug.print "False"
End If
I understand why using sheets() qualifiers makes the code work. For example, if the range name is scoped to the worksheet, then Sheets() qualifier is required. However, I don't want to change all of my VBA code (I have a lot of it) to qualify Range() objects with the Sheet() object when the range_name is scoped to the workbook level. I hope there is something I inadvertently changed that can be reversed to restore functionality.
Can anyone tell me why the code used to work without the Sheet() object qualifier? Am I missing a Library or, perhaps, do I have two Libraries that are conflicting? How can I get this functionality back?
BTW, https://learn.microsoft.com/en-us/office/vba/excel/concepts/cells-and-ranges/refer-to-named-ranges confirms that Range() should work with named ranges scoped to the workbook level.