0

I am using the following code to name a range:

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

var rangeToName = sheet.getRange(column, column - 1, 1,values.length + rowOffset);
var rangeName = 'F' + '2';

ss.setNamedRange(rangeName, rangeToName); // SCRIPT CRASHES HERE

When executing this script, it fails with the error message: The name you specified for this range is not a valid name.

I get this error whenever I use a concatenated string (it does not matter if I use to delimit the string with ' or ").

How can I create the name of a range by concatenating two strings or a string and number?

2 Answers 2

1

As indicated:

The specified range name is ambiguous with a cell reference.

For more information, see Named and protected ranges.

Sign up to request clarification or add additional context in comments.

Comments

1

I have found the error:

The name for the range may not look like a reference to a cell, e.g. "F2" is an invalid name as it could be a cell. A name may not contain a "-" character.

1 Comment

"A name may not contain a "-" character."--helped

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.