Reputation: 77
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);
};
Upvotes: 1
Views: 71
Reputation: 201513
In that case, how about the following modification?
var rffilename = spreadsheet.getRangeByName("rfFileName");
var rffilename = spreadsheet.getRangeByName("rfFileName").getValue();
getValue()
.getDisplayValue()
instead of getValue()
, when you want to use the display value of the cell.Upvotes: 1