I am an expert VBA programmer struggling to come to grips with Google Scripts in Google Sheets. I'm trying to create a copy of the active file and name it from a Named Range. I can get it to copy, but the name of the new file ends up being "Range".
Here is the code I have.
function SaveFileAndCopy() {
var spreadsheet = SpreadsheetApp.getActive();
var rffilename = spreadsheet.getRangeByName("rfFileName");
spreadsheet.copy(rffilename);
};
CodePudding user response:
In that case, how about the following modification?
From:
var rffilename = spreadsheet.getRangeByName("rfFileName");
To:
var rffilename = spreadsheet.getRangeByName("rfFileName").getValue();
- In this case, please retrieve the cell value using
getValue()
. - Or, you might be able to also use
getDisplayValue()
instead ofgetValue()
, when you want to use the display value of the cell.