Updated: In French Excel version 1902 (build 11328.20438) this code is failing:
Public Sub TestOne()
Dim n As Name
Set n = ActiveSheet.Names.Add("TestOne", ActiveSheet.Range("A1:E8"))
Debug.Print n.RefersTo
Debug.Print n.RefersToRange.Address
Set n = ActiveSheet.Names.Add("TestTwo", ActiveSheet.Range("A10:E18"))
Debug.Print n.RefersTo
n.Comment = "zoltan"
Debug.Print n.RefersTo
Debug.Print n.RefersToRange.Address '<--- error 1004 thrown here
End Sub
The immediate window shows:
=Feuil1!$A$1:$E$8
$A$1:$E$8
=Feuil1!$A$10:$E$18
=Feuil1!L10C1:L18C5
In my English Excel version 1910 (build 12130.20344) the same code produces
=Sheet1!$A$1:$E$8
$A$1:$E$8
=Sheet1!$A$10:$E$18
=Sheet1!$A$10:$E$18
$A$10:$E$18
(previous iteration of question; didn't have full user feedback on test case) -----------
In the code below, I'm creating a named range an passing in a range as the RefersTo parameter. Works fine in English Excel (I happen to be using Excel 365 64-bit). For some reason, even though r.Address in the Immediate window shows B3:E8, the named range that is created shows 'SheetName'!'L3C3':'L5C8' (not the exact values) which is the French version of R1C1. But n.RefersToRange throws an error because it no longer recognizes the RefersTo as a range.
Is this issue familiar to anyone and is there a good workaround? Best I can tell so far, this issue has only popped up in one place in the application code and I've never seen anything like this before on the English side.
Dim n As Name
Dim r As Range
Set r = ActiveSheet.Range("B3:E8")
Set n = ActiveSheet.Names.Add("TestOne", r)
debug.print n.RefersToRange.Columns.Count '<--- error is here because RefersToRange does not return a Range reference