avoid modifying range name references that are not affected, fdo#86518

Change-Id: I0822fb96ebcb30326bcdd88f3900e6e01c85bcf5
For external data sources this variable can be null, fdo#83534

Change-Id: I8c47cf078b4772fcdba0993880740c22114f1b45